PDA

View Full Version : [SOLVED] ISBLANK problem



snoopies
07-05-2005, 10:50 PM
Hi all,

How can I apply ISBLANK function in VBA?


If ISBLANK(Cells(1,1)) Is True Then
Do sth....

It seems ISBLANK doesn't work in this case..


I want to make sure there is no " ' " in the cell...

Thanks a lot!

Ken Puls
07-05-2005, 11:03 PM
Hi Elita,

IsBlank doesn't actually exist in VBA.

For another approach, you may want to try evaluating the length of the cell contents. If it's zero, your cell is blank.


If Len(Cells(1,1)) = 0 Then

HTH,

sheeeng
07-05-2005, 11:28 PM
Try IsNull or IsEmpty....


Quote from MSDN:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctisnull.asp

Use the IsNull function to determine whether an expression contains a Null value. Expressions that you might expect to evaluate to True under some circumstances, such as If Var = Null and If Var <> Null, are always False. This is because any expression containing a Null is itself Null, and therefore, False.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctisempty.asp

IsEmpty returns True if the variable is uninitialized, or is explicitly set to Empty; otherwise, it returns False. False is always returned if expression contains more than one variable.

HTH :friends:

snoopies
07-05-2005, 11:32 PM
Hi Ken,

I've tried
If Len(Cells(1,1)) = 0 Then, however... if there is a ' (a text symbol?) in the cell, the length is still 0... that's why I try to see if I can see ISBLANK in VBA..

Ken Puls
07-05-2005, 11:34 PM
Well go figure that! I see what you mean. IsNull should work for you as Sheeeng suggested.

Cheers!

snoopies
07-06-2005, 08:18 AM
THX ALL!!:)