Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA recognizing empty cells in excel

Status
Not open for further replies.

paulo33

Technical User
Oct 31, 2002
15
0
0
AU
Does anybody know how to make VBA check for empty cells in excel??
I have a bit of code that searches recursively until it finds the first ocurrence of cell = Null or cell = "" and then assigns this rownumber to a variable.
When I refer to this variable r, the first time, it works fine, but if there has been something in the cells, and has been deleted, then the loop goes all the way down to where the cells have never been filled before.

Any ideas????
Thanks in advance.
 
Hi paulo33,

Be very wary of using nulls. Empty cells are not null, and checking for "= null" in code always returns False. Checking = "" should be sufficient and should find your empty cell whether or not it previously held data.

One other possibility is that you have some spaces in your cells in which case try using the Trim function to strip them off.

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top