Macro question

[Solved/Closed]
Report
-
 Jay -
Hello,

I'm trying to write a macro in excel 07 to select the last row in a range. I want it to select the last row of the range only. Does anyone know how to do that?

For ex.

A3 = 5
A4 = 7
A5 = 9

I can obviously get the macro to specifically select row C, but if I add more rows or select rows, it will be off.

Thanks in advance!

2 replies

Posts
1
Registration date
Sunday December 27, 2009
Status
Member
Last seen
December 28, 2009

Oops sorry, meant I could select the row A5 is in. So basically want the macro to select the last row of data in a specific range.
Hi,

Try this line of code:
Range("A3").End(xlDown).EntireRow.Select


If you want to select the row below your range, i.e. the first empty row, try this:
Range("A3").End(xlDown).Offset(1, 0).EntireRow.Select


Best regards,
Trowa
Thanks Trowa! That's exactly what I needed.