Testing for null or empty

  • Thread starter Thread starter gwgeller
  • Start date Start date
G

gwgeller

Hello, I need to test a cell to see if it contains anything. If not
will delete its row. Sometimes the cell is "empty" and sometimes it i
"null". Testing for both seems like too much. I will reuse this cod
over and over.
My question is, is there a way I can make each cell not containin
info "null" or "empty" so I just have to test for one of them. M
thought is to make a sub that will go through the sheet and make eac
non-used cell "null". When I go to test later I can then just test fo
each cell being null. Or if there is some simpler way to test for bot
instead of isNull(cell1) or isEmpty(cell1). I could make my own su
that does it, but I don't want to reinvent the wheel if one is ou
there.
Thanks
 
Please share with me how you would make the cell contain NULL and return
true for an IsNull Test (since you say you could change all blanks to NULL).

for each cell in selection
if Trim(cell.Text) = "" then
cell.EntireRow.Delete
End if
Next
 
That is what I was thinking of doing, I was hoping someone would know
 
I have only seen a few uses for isnull in Excel VBA and I can't recall a
situation where you can get a true response from IsNull from a cell (there
could be a way, but unlikely you will encounter it. I don't think bringing
in Null fields from an external database puts a Null in the field, but I
can't say I have tested it.)

Anyway, I showed you a way that should work.
 

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

Back
Top