ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Test for empty cell (https://www.excelbanter.com/excel-programming/362699-test-empty-cell.html)

Sonnich

Test for empty cell
 
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


Chip Pearson

Test for empty cell
 
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




"Sonnich" wrote in message
ups.com...
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




Sonnich

Test for empty cell
 
Restarting it was a good idea... it worked :-)

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



Sonnich wrote:
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




All times are GMT +1. The time now is 01:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com