Macro question

Solved/Closed
Jay - 27 Dec 2009 à 22:44
 Jay - 28 Dec 2009 à 10:07
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 responses

jaycr8965 Posts 1 Registration date Sunday 27 December 2009 Status Member Last seen 28 December 2009
28 Dec 2009 à 01:01
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.