Testing for blanks cells
Hi Keith,
You could wrap your procedure in an If...Then block so that it only
processes non-empty columns.
Also, to find the last row in a column you should work from the bottom
upward. If there are empty cells between the last row and first rows, use
another If...Then block to skip the blanks.
Example: (assumes you are iterating through each cell in the range)
Dim c As Range
Dim lLastRow as Long
lLastRow = Range("AI" & Rows.Count).End(xlUp).Row
If lLastRow 2 Then 'enter the procedure
For Each c In Range("AI2:AI" & lLastRow)
If Not c = "" Then 'continue
'do stuff
End If
Next c
End If
Note that I used an empty string for the test so that it includes cells with
formulas that return an empty string. (using IsEmpty will include such a cell)
HTH
Regards,
Garry
|