G
Guest
I have a spreadsheet with a variable number of rows, which I need to sort by
4 columns (A, B, D, and C). Via menu, you can only sort by 3 columns
w/Excel, so I recorded the macro and tried to edit it to add the 4th
Key...but it doesn't work.
I've edited macros before without an error, so I'm somewhat at a loss to
figure out what the heck I'm doing wrong. Is Excel simply incapable of
sorting by 4 columns? Will I have to use QPro for this file?
Here is the 3 column sort code, as recorded:
Sub SortxManager()
'
Rows("4:4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Key2:=Range("B4") _
, Order2:=xlAscending, Key3:=Range("D4"), Order3:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Range("A4").Select
End Sub
Here is the 4 column version that doesn't work:
Sub SortxManager()
'
Rows("4:4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Key2:=Range("B4") _
, Order2:=xlAscending, Key3:=Range("D4"), Order3:=xlAscending, _
Key4:=Range("C4"), Order4:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal, DataOption4:=xlSortNormal
Range("A4").Select
End Sub
What am I doing wrong? Thanks in advance...
4 columns (A, B, D, and C). Via menu, you can only sort by 3 columns
w/Excel, so I recorded the macro and tried to edit it to add the 4th
Key...but it doesn't work.
I've edited macros before without an error, so I'm somewhat at a loss to
figure out what the heck I'm doing wrong. Is Excel simply incapable of
sorting by 4 columns? Will I have to use QPro for this file?
Here is the 3 column sort code, as recorded:
Sub SortxManager()
'
Rows("4:4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Key2:=Range("B4") _
, Order2:=xlAscending, Key3:=Range("D4"), Order3:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Range("A4").Select
End Sub
Here is the 4 column version that doesn't work:
Sub SortxManager()
'
Rows("4:4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Key2:=Range("B4") _
, Order2:=xlAscending, Key3:=Range("D4"), Order3:=xlAscending, _
Key4:=Range("C4"), Order4:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal, DataOption4:=xlSortNormal
Range("A4").Select
End Sub
What am I doing wrong? Thanks in advance...