Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Choose data from a selected range and put result in new column | Excel Worksheet Functions | |||
Macro to find empty cell and select range to print selected. | Excel Programming | |||
Find Findnext in selected range | Excel Programming | |||
Referencing a Column in a Selected Range of Columns | Excel Programming | |||
how to find last row/col index within a selected range | Excel Programming |