I was just tweaking with a data in VBA and was stuck at one problem. I was trying to impute a zero value with a "" and a non zero value with a column header.
My data looks like :
Customer Pasta Sandwich Pizza Burger
X 01 00 01 00
Y 01 01 00 01
Z 00 01 00 01
A 00 00 01 01
B 01 01 01 01
Kindly note the data is in TSV format and it has numerous columns. Basically the data is variable and one can expect different number of columns in different data. I want to build my Macro so flexible that it can be executed on any similar data.
As of now i was able to achieve the code as below :
Sub clearzero()
Dim rng As Range
For Each rng In Range("B2:XFD1048576") 'Also i have used XFD1048576 as the end of workbook ( which i know is not feasible, if anyone can suggest how to select the data dynamically then i would be glad as well )
If rng.Value = "00" Then
rng.Value = ""
If rng.Value = "01" Then
rng.Value =??
Next
End Sub
I am not able to figure out ?? in my code. My output would be like the below:
Can anyone suggest on the same?
Thanks
rng.Value = Cells(1, rng.column).value(assuming your header is in row 1). Unless you expect the headers to give you a positive results with your conditions, you could simply useFor Each rng In Sheet.usedRange