Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting on more than one column
How can I sort numbers from 1-7 in column 'C' ascending and then sort the
dates in column 'A' in descending order for each group of numbers in 'C' with one piece of code? A C 15/08 2 14/08 3 16/08 2 17/08 3 16/08 3 15/08 1 Hope that makes sense!! -- Traa Dy Liooar Jock |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting on more than one column
Try this:
Range("A1:C7").Select Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("A2") , Order2:=xlDescending, Header:=xlYes You may have to change "Range("A1:C7")" to fit your data range. HTH, Matthew Pfluger "Jock" wrote: How can I sort numbers from 1-7 in column 'C' ascending and then sort the dates in column 'A' in descending order for each group of numbers in 'C' with one piece of code? A C 15/08 2 14/08 3 16/08 2 17/08 3 16/08 3 15/08 1 Hope that makes sense!! -- Traa Dy Liooar Jock |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting on more than one column
maybe something like this: Sub sort_cols() Dim ws As Worksheet Set ws = Worksheets("Sheet1") With ws.Range("A1:C7") .Sort Key1:=ws.Range("C1"), Order1:=xlAscending, Key3:=ws.Range("A1") _ , Order3:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption3 _ :=xlSortNormal End With End Sub -- Gary "Jock" wrote in message ... How can I sort numbers from 1-7 in column 'C' ascending and then sort the dates in column 'A' in descending order for each group of numbers in 'C' with one piece of code? A C 15/08 2 14/08 3 16/08 2 17/08 3 16/08 3 15/08 1 Hope that makes sense!! -- Traa Dy Liooar Jock |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting on more than one column
On Sep 28, 10:10 am, Jock wrote:
How can I sort numbers from 1-7 in column 'C' ascending and then sort the dates in column 'A' in descending order for each group of numbers in 'C' with one piece of code? A C 15/08 2 14/08 3 16/08 2 17/08 3 16/08 3 15/08 1 Hope that makes sense!! -- Traa Dy Liooar Jock Either choose DataSort... and choose "Column C" (ascending) and 'then by' "Column A" (descending) or code: Range("A1:C6").Select Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Key2:=Range("A1") _ , Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom Brian Herbert Withun --- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sorting a Pivot Table Column that is not the first column... | Excel Worksheet Functions | |||
How do I limit sorting a column to the column? | Excel Worksheet Functions | |||
Sorting 1 column into two | Excel Discussion (Misc queries) | |||
Right column doesn't change when sorting left column. | Excel Discussion (Misc queries) | |||
sorting a column | Excel Programming |