Getting a row number of the last row?

Getting a row number of the last row?

Post by andycharge » Wed, 14 Apr 2004 20:19:30


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

How do I get this?


Thanks
 
 
 

Getting a row number of the last row?

Post by Frank Kabe » Wed, 14 Apr 2004 20:23:52

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


dynamically

 
 
 

Getting a row number of the last row?

Post by Patrick Mo » Wed, 14 Apr 2004 20:30:01

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
------------------
I feel Great!

selection dynamically
 
 
 

Getting a row number of the last row?

Post by Tom Ogilv » Wed, 14 Apr 2004 21:08:12

selection.rows(selection.rows.count).row

--
Regards,
Tom Ogilvy
 
 
 

Getting a row number of the last row?

Post by Robert McC » Fri, 16 Apr 2004 00:59:20

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




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.yqcomputer.com/ ).
Version: 6.0.655 / Virus Database: 420 - Release Date: 09/04/2004