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 Range to Variable for Sort

I have data being pasted into a worksheet from which I need to do a unique
sort on the first column (EmployeeID) and copy the results to another
worksheet. My problem is with referencing the range address. Since the number
of rows can vary, what is the proper way to get that full range into the
source line. So far I have this:

Dim SourceArea, TargetArea as Variant

Set TargetArea = Application.Sheets("Current").Range("A5")
Application.Sheets("Working").Activate
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select '<-Gets all rows
Set SourceArea = ActiveCell.Address

Range([SourceArea]).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range([TargetArea]), Unique:=True

If Excel has a better way to reference a range, please let me know. My first
instinct is to assign it to a variable. As always thanks for the help.
--
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 range to variable for sort Michael Conroy Excel Programming 2 November 11th 09 06:48 AM
Sort by a Variable Range asmithbcat Excel Programming 2 October 1st 09 08:46 PM
Macro to Sort A-Z a variable range of cells Keith B Excel Discussion (Misc queries) 1 September 9th 09 03:31 AM
VBA Variable Range Sort Tony Excel Discussion (Misc queries) 4 April 9th 09 08:21 PM
Sort variable range in descending order J.W. Aldridge Excel Programming 3 March 19th 09 06:36 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"