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
 
It should be .Sort not ,Sort
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,216,109
Messages
6,128,884
Members
449,477
Latest member
panjongshing

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