IsEmpty on a range/array
Hi Benb,
Cells(Rows.Count, "A")
should have been:
Cells(Rows.Count, "A").End (xlUp)
Similarly
Cells(Rows.Count, "A")(2)
should have been:
Cells(Rows.Count, "A").End (xlUp)(2)
---
Regards,
Norman
"Norman Jones" wrote in message
...
Hi Benb,
To check if a range of cells is empty, try something like
If Application.CountA(Range("A1:A20")) = 0 Then
'Range is empty
Else
'Range is not empty
End If
To return the last populated cell in column A:
Cells(Rows.Count, "A")
and to return the following blank cell:
Cells(Rows.Count, "A")(2)
---
Regards,
Norman
"benb" wrote in message
...
I need to find the last row of a column that still contains data. I
cannot
use Do While Not IsEmpty (or something similar) because there are blank
cells
mixed into the column. The best solution I can come up with is finding
the
cell at which the 20 or so cells above contain data and the 20 or so
cells
below are empty. The problem: IsEmpty does not seem to work in
evaluating a
range. How can I evaluate if Cells(1,1) to Cells(20,1) contain data
while
Cells(21,1) to Cells(40,1) are empty?
|