empty cells - best way of testing for them

C

Chris Strug

Hi,

I have a simple loop in which I loop through a column of cells.During each
iteration I wish to test to see if the cell is empty (has no value, which is
to say, it might have once had a value and been deleted, it may contain an
empty string or it may simply have never been used). However I'm unsure of
the best way to do this.

For example, the isnull function appears to recognise empty strings as not
null values (for example if that cell has at one point contained data and
has now been cleared).

I have recently discovered the IsEmpty function that appears to do what I
want which is detect when a cell contains no data - be that a null or an
empty string.

However I don't know much about the function - while it appears to work is
it the best way to test for an empty cell.

Any and all assistance is gratefully received.

Kind thanks

Chris Strug.
 
J

Jim Cone

Chris,

I prefer to use the Len function to check for blank/empty worksheet cells....

If Len(MyCell) then
'do something
End if

It seems to be faster than other methods and has the benefit of ignoring " ' " - the single apostrophe

Regards,
Jim Cone
San Francisco, CA
 
D

Dave Peterson

I think it's the safest way to really test if the cell is empty.

If it's a formula that returns "":
=if(a1>3,"big","")

then this cell isn't empty, but the length of the cell's value would be 0.
 
C

Chris Strug

Dave Peterson said:
I think it's the safest way to really test if the cell is empty.

If it's a formula that returns "":
=if(a1>3,"big","")

then this cell isn't empty, but the length of the cell's value would be 0.

Dave / Jim,

Thanks for the reply. On balance I think I'll just test the length of the
cell value but thanks to you both for your advice.

Cheers

Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top