VBA Sort multiple columns

maclachlan19

Board Regular
Joined
Jul 8, 2013
Messages
53
I'm trying to run some code to sort multiple columns at once. I get an error:
Compile error: Named argument not found


VBA Code:
Range("Managers").Sort Key1:=Range("Q4"), Order1:=xlDescending, _
                        Key2:=Range("G4"), Order2:=xlDescending, _
                        Key3:=Range("H4"), Order3:=xlAscending, _
                        Key4:=Range("F4"), Order4:=xlDescending, _
                        Key5:=Range("I4"), Order5:=xlAscending, _
                        Header:=xlYes
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
This is now working, thanks Guys
Here is the final code for others searching this thread.

VBA Code:
With Range("Managers")
    .Sort key1:=Range("I4"), Order1:=xlAscending, Header:=xlYes
    .Sort key1:=Range("F4"), Order1:=xlDescending, Header:=xlYes
    .Sort key1:=Range("H4"), Order1:=xlAscending, Header:=xlYes
    .Sort key1:=Range("G4"), Order1:=xlDescending, Header:=xlYes
    .Sort key1:=Range("Q4"), Order1:=xlDescending, Header:=xlYes
End With
 
Upvote 0

Forum statistics

Threads
1,224,800
Messages
6,181,045
Members
453,014
Latest member
Chris258

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top