Thread
:
Sorting multiple range using a macro
View Single Post
#
3
Posted to microsoft.public.excel.programming
Don Guillett[_4_]
external usenet poster
Posts: 2,337
Sorting multiple range using a macro
Let us know if this works by putting your ranges in a list
c1:d21
c22:d400
etc
Sub sortfromloop()
For Each c In Selection
'MsgBox c
x = Left(c, InStr(c, ":") - 1)
'MsgBox x
'Range("C1:D20").Sort Key1:=Range("C1"), Order1:=xlAscending
Range(c).Sort Key1:=Range(x), Order1:=xlAscending
Next c
End Sub
Sub Macro5()
myname = ActiveCell
myref = ActiveCell.Offset(, 1).Address
Names.Add Name:=myname, RefersTo:=myref
End Sub
--
Don Guillett
SalesAid Software
"onlinepredator " wrote in
message ...
Hi,
I am tyring to use a macro to sort a group of ranges C1:D20, C21:D40,
....C31:D400. i need to sort each of these ranges based on entries in
coulmn C. There are 20 ranges here. Heres the code that I use to sort
the first two ranges.....
Range("C1:D20").Select
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("C21:D40").Select
Selection.Sort Key1:=Range("C21"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
but i would prefer to use a for loop so that in case i change the
spreadsheet later it would be easy for me to change the code
too........
Dhanush
---
Message posted from
http://www.ExcelForum.com/
Reply With Quote
Don Guillett[_4_]
View Public Profile
Find all posts by Don Guillett[_4_]