Test for empty cell

  • Thread starter Thread starter Sonnich
  • Start date Start date
S

Sonnich

Hi!

I have a sheet, where I have a list of integers - if present - the
field might be empty.
How do I detect whether it is empty?

Using
r = MyFile.Sheets(1).Cells(i, 4)
and later using r cuases problems, I'd like to set it to -1 in cases
where it is empty.

I get the file from elswhere, the contest of it is unknown

BR
Sonnich
 
Try

If MyFile.Sheets(1).Cells(i, 4) = "" Then
r = -1
Else
r = MyFile.Sheets(1).Cells(i, 4)
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Restarting it was a good idea... it worked :-)

If MyFile.Sheets(1).Cells(i, 3).Text <> "" Then
 

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