Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I check if a value is 0 in Excel? (If there are blank cells in the same column)

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading