return row number

  • Thread starter Thread starter Jonathan Vickers
  • Start date Start date
J

Jonathan Vickers

Hi,

How can I return the row number (in VB inside a macro) of the last
data-containing cell in a particular column?


Thanks for any help,

Jon
 
Jon,

Try something like the following:

Dim RowNum As Long
RowNum = Cells(Rows.Count,"A").End(xlUp).Row

Change the "A" to the column of interest.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Thanks for the help, Chip.

I want to use the result in the next part of the code in place of the 400:

Rows("6:400").Sort ..............

but it doesn't seem to work.

Is there something else that I need to do, or should I be approaching this
in another way?

Thanks once again for any help,

Jon
 
Rows("6:" & rowNum).Sort


demo'd from the immediate window:

rowNum = 600
? Rows("6:" & rowNum).Address
$6:$600
 
Back
Top