IsNull in Excel VBA

I’ve come from a background of microsoft access, SQL Server and ASP programming so am pretty familiar with the concept of NULL.

I’ve recently been working on some Excel VBA code and was puzzled when an empty cell would be reported as not being NULL or empty string.

For anyone else coming across this problem have a look at the vbNullString constant which seems to replace NULL in some cases.


2 Responses to “IsNull in Excel VBA”

  1. 1 movefirstblog June 28, 2008 at 1:14 am

    In the case I was having trouble with IsNull was returning FALSE for a cell formated as a date but with the contents deleted from the cell.

    Here equal to vbNullString evaluated to TRUE.

    Again it seems that using IsNull, IsBlank or equal to vbNullString is a matter of using the right one in the right situation.

  2. 2 JP July 22, 2008 at 10:11 pm

    Don’t forget “Not” and “IsEmpty” to make things even more interesting.

    (ps- the trackback on your post is from a splog.)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog Stats

  • 226,374 hits




%d bloggers like this: