how to check if a cell is populated or not?

  • Thread starter Francesco Sblendorio
  • Start date
S

Sameh Ahmed

Hello there
I am using a nested loop to read from an Excel workbook.
When I reach the first unused Cell, an "Object reference not set to an
instance of an object" error is generated.
How do I check if the cell if used or not?
I tried:
xbook.Application.Cells(I, 1).value().ToString.Length <> 0
xbook.Application.Cells(i, 1).value() = Nothing
and both did not work.
Any ideas?
Regards
Sameh
 
F

Frank Kabel

Hi
try
If IsEmpty(xbook.worksheets("sheet1").Cells(I, 1)) Then
' do stuff...
End If
 
S

Sameh Ahmed

I am working on .net visual basic
i added
Imports Microsoft.Office.Interop.Excel
but i still give the error; Name 'isempty' is not declared.
any ideas?
 
Top