Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Last Row of Selection

Hello,
Is there a different way of getting the last row of a selection? The first
row is selection.rows(1).row, but I can't get the last row without counting
rows and subtracting one.

lastrow = selection.rows(1).row+selection.rows.count-1

Thanks.

Bill


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Last Row of Selection

What is wrong with that way? You do't need rows(1), just

lastrow = selection.row+selection.rows.count-1

An alternative is

LastRow = rng(rng.Count).Row

--
HTH

Bob Phillips

"Bill" wrote in message
link.net...
Hello,
Is there a different way of getting the last row of a selection? The

first
row is selection.rows(1).row, but I can't get the last row without

counting
rows and subtracting one.

lastrow = selection.rows(1).row+selection.rows.count-1

Thanks.

Bill




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Last Row of Selection

LastRow = Selection.Rows(Selection.Rows.Count).Row

Not much prettier and much more difficult to read.

Mike F
"Bill" wrote in message
link.net...
Hello,
Is there a different way of getting the last row of a selection? The
first row is selection.rows(1).row, but I can't get the last row without
counting rows and subtracting one.

lastrow = selection.rows(1).row+selection.rows.count-1

Thanks.

Bill



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Last Row of Selection

Maybe easier to read:

with selection
LastRow = .Rows(.Rows.Count).Row
end with

and I like:

with selection
LastRow = .cells(.cells.Count).Row
end with

(just to be different!)


Mike Fogleman wrote:

LastRow = Selection.Rows(Selection.Rows.Count).Row

Not much prettier and much more difficult to read.

Mike F
"Bill" wrote in message
link.net...
Hello,
Is there a different way of getting the last row of a selection? The
first row is selection.rows(1).row, but I can't get the last row without
counting rows and subtracting one.

lastrow = selection.rows(1).row+selection.rows.count-1

Thanks.

Bill


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
Object Type of a selection... counting rows in a selection Acid-Sky[_2_] Excel Programming 3 August 23rd 05 09:53 AM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM


All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"