goto last cell with data

W

W

Hi all,

I export a query from Access on which I have to perform statistical analysis.
The data always start at cell A2, but can stop at whatever cell in the A
range. E.g. it could be A345 or A21.

How can I, programmatically, position myself on A2 and then select from A2
till the last "filled" cell, e.g. A345 ?

Thank you,

W
 
G

Gary''s Student

Sub dural()
n = Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:A" & n).Select
End Sub
 
C

Charlotte E.

And, in case you don't know, Gary's code can be made into one single line:

Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row).Select


And in case, you want to make sure that selection isn't done 'backward', if
no cell with data is found in column A:

Range("A2:A" & WorksheetFunction.Max(2, Cells(Rows.Count,
"A").End(xlUp).Row)).Select


Sorry, Gary :)

CE
 
Top