![]() |
How do I create a macro that will select a range that can vary in
In Excel, the keystrokes Shift+End+Arrow(any direction) selects the data from
the cell where the keystroke was invoked to the end of the data (in whichever direction was indicated). I used these keystrokes to create a macro to select data in a particular column. It worked fine on my test file. However, if I use that same macro on a file with a different number of data rows, the macro does not make the selection in the same manner. Whatever cells were selected on the recording is what is included in the macro coding. Is there a way to edit the macro where it will mimic the Shift+End+Arrow keystrokes? I want to select the data in a column, not a specific hard-coded cell range. |
How do I create a macro that will select a range that can vary in
This selects the activecell to the last used cell in that column:
with activesheet .range(activecell, .cells(.rows.count,activecell.column).end(xlup)).s elect end with smokief wrote: In Excel, the keystrokes Shift+End+Arrow(any direction) selects the data from the cell where the keystroke was invoked to the end of the data (in whichever direction was indicated). I used these keystrokes to create a macro to select data in a particular column. It worked fine on my test file. However, if I use that same macro on a file with a different number of data rows, the macro does not make the selection in the same manner. Whatever cells were selected on the recording is what is included in the macro coding. Is there a way to edit the macro where it will mimic the Shift+End+Arrow keystrokes? I want to select the data in a column, not a specific hard-coded cell range. -- Dave Peterson |
How do I create a macro that will select a range that can vary in
Sub select_alldown()
'select to bottom of selected column(s) Set myRange = Range(Selection, Cells(Rows.Count, Selection.Column).End(xlUp)) MsgBox "Range selected is " & myRange.Address End Sub Gord Dibben MS Excel MVP On Thu, 3 May 2007 11:08:01 -0700, smokief wrote: In Excel, the keystrokes Shift+End+Arrow(any direction) selects the data from the cell where the keystroke was invoked to the end of the data (in whichever direction was indicated). I used these keystrokes to create a macro to select data in a particular column. It worked fine on my test file. However, if I use that same macro on a file with a different number of data rows, the macro does not make the selection in the same manner. Whatever cells were selected on the recording is what is included in the macro coding. Is there a way to edit the macro where it will mimic the Shift+End+Arrow keystrokes? I want to select the data in a column, not a specific hard-coded cell range. |
All times are GMT +1. The time now is 08:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com