Getting a row number of the last row?

A

andycharger

I need to get the row number of my last row in a selection dynamically

How do I get this?


Thanks
 
F

Frank Kabel

Hi
if you want the last row in your current selection try
sub foo()
dim rng as range
dim lastrow as long
set rng = selection
lastrow = rng.row+rng.rows.count-1
msgbox lastrow
end sub
 
P

Patrick Molloy

if rTarget is your range, then
rTarget.Row is the first row,
rTarget.Rows.Count is the number of rows,
thus then last row is
with rTarget
lastrow = .Row + .Rows.Count -1
end with

Patrick Molloy
Microsoft Excel MVP
 
R

Robert McCurdy

MsgBox Selection.Rows.Count + Selection.Row - 1

Just in case you are looking for the last row of your selection on your workbook.


Regards Robert
 
Top