Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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.


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
How do I select a range using a macro? brettopp Excel Discussion (Misc queries) 3 November 8th 06 11:40 PM
Using macro to select a range Rob Excel Worksheet Functions 3 November 6th 06 08:31 PM
select a range in a macro Andrew Excel Discussion (Misc queries) 3 May 10th 06 08:45 PM
Macro €“ select all cells in current range Mary Ann Excel Discussion (Misc queries) 3 December 12th 05 07:19 AM
How can I vary graph color by range value pcover Charts and Charting in Excel 3 June 6th 05 01:14 AM


All times are GMT +1. The time now is 09:13 PM.

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

About Us

"It's about Microsoft Excel"