I have a table on Excel, and there is column B which contains numbers (from 0 to 240) but it also contains blanks.
I have a code that looks something like thhis
for i = 2 to 500
My_Value = Worksheets("MachineData").range("B" & i).value
if My_Value = 0 then
'Do Something
end if
next i
The problem with this is that Excel thinks that blank cells are also 0. so how can I check for when the value of the cell is 0 and only 0?
CodePudding user response:
I believe you should check for the value being zero, combined with the length of that value, being one. (Length zero means that nothing is filled in)
In code: (not tested)
if ((My_Value = 0) And Len(My_Value) = 1) then