Finding first and last cells containing data


Posted by Jerry Weinstein on June 06, 2001 9:55 AM

How can I (keystrokes or VBA)
1. Find the first cell after column x in a row that has data
2. Find the last cell in a row after column x that has data

I want to write a macro that will do this for large file but I'm sure of the above technique.

Thanks.



Posted by Dave on June 06, 2001 10:39 AM


Not really sure what you need since your explanation can be interpreted in different ways. But try this :-

(1)
If Cells(1, x + 1) <> "" Then
Cells(1, x + 1).Select
Else
Cells(1, x + 1).End(xlDown).Select
End If
End Sub

(2)
Cells(65536, x + 1).End(xlUp).Select