LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Assign range to variable for sort

I am trying to do a unique sort to another location and I recorded this code.

Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A2:A69").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"AA1"), Unique:=True

The next time there might be more than sixty-seven rows of data, so I did
this, which does not work.

Dim TargetArea as Range
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Set TargetArea = Selection.ActiveCell
Range([TargetArea]).... the rest of the sort code

How does one grab a range of cells, assign it to a variable, and refer to it
further down in the code? If this is not the proper way to do it, please feel
free to let me know. And thanks in advance for any help on this.

--
Michael Conroy
Stamford, CT
 
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
assign variable to a range Alberto Ast[_2_] Excel Programming 1 October 23rd 09 03:01 AM
Assign copied range to a variable johnmasvou Excel Programming 3 March 20th 09 10:44 AM
VBA Excel how to assign name in variable range Mouimet Excel Programming 4 November 14th 08 05:56 PM
range variable won't assign (chartobject.topleftcell property) Matthew Dodds Excel Programming 2 November 16th 05 02:25 PM
How to assign a variable in a range select Paul Excel Programming 5 June 3rd 05 11:50 PM


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