Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Find last row and column in a selected range

Fullers,

Be careful with Activecell - it isn't always the top-left cell:

Sub Test()

SelectionAddress = Selection.Address
FirstRow = Selection(1).Row
FirstColumn = Selection(1).Column
LastRow = FirstRow + Selection.Rows.Count - 1
LastColumn = FirstColumn + Selection.Columns.Count -1
'or
'LastRow = Selection(Selection.Cells.Count).Row
'LastColumn = Selection(Selection.Cells.Count).Column

End Sub

HTH,
Bernie
MS Excel MVP


"fullers" wrote in message
...
I want to be able to have a user highlight a range of cells and then run a
macro. What I need from this macro is to obtain the range address, the first
row & column and the last row & column.

At the moment I can get the address and the first row, column with the
following macro:

Sub Test()

SelectionAddress = Selection.Address
FirstRow = ActiveCell.Row
FirstColumn = ActiveCell.Column

End Sub

I cannot figure out how to get the last row, column. Any ideas?

Thanks in advance.



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
Choose data from a selected range and put result in new column Betsy Excel Worksheet Functions 2 July 1st 06 04:13 AM
Macro to find empty cell and select range to print selected. [email protected] Excel Programming 1 May 15th 06 09:05 AM
Find Findnext in selected range looloo[_2_] Excel Programming 2 January 25th 05 06:51 PM
Referencing a Column in a Selected Range of Columns Rob G Excel Programming 3 October 21st 04 05:21 PM
how to find last row/col index within a selected range Jeff Excel Programming 2 October 6th 04 03:58 PM


All times are GMT +1. The time now is 09:59 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"