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: 73
Default Multiple Sort Ranges via VBA Q

Code below sorts 2 Range Names called "Sort1" & "Sort2". It uses Column I as the Sort field from Largest down

I have over 50 of these Ranges, is there anyway to short circuit the code below to include all 50 of these Sort Ranges?

Sub SortProductSales()

Application.Goto Reference:="Sort1"
ActiveWorkbook.Worksheets("Input").Sort.SortFields .Add Key:=Range("I15:I22") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Input").Sort
.SetRange Range("F15:I22")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Application.Goto Reference:="Sort2"
ActiveWorkbook.Worksheets("Input").Sort.SortFields .Add Key:=Range("I23:I30") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Input").Sort
.SetRange Range("F23:I30")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
 
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
Sort and align 2 ranges u473 Excel Programming 1 June 24th 10 11:22 PM
Sort 2 ranges with same Key jlclyde Excel Discussion (Misc queries) 3 November 4th 08 08:28 PM
How do I sort by ranges? Clevernewt Excel Discussion (Misc queries) 2 May 23rd 08 09:07 PM
Limiting Sort Ranges DCSwearingen Excel Discussion (Misc queries) 1 June 9th 06 01:24 AM
Expanding ranges after sort??? Simon Lloyd[_670_] Excel Programming 2 January 1st 06 05:45 PM


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