Multiple Sorting

Ody

Board Regular
Joined
Oct 14, 2010
Messages
215
Good day all,

I'm trying to accommodate a request for an auto sort upon a WB opening.

I've used the macro recorder to to acquire the following:

Range("G9").Select
Range("A9:S100").Sort Key1:=Range("G9"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1:P1").Select
And then I've added this to my ThisWorkbook code. It works fine. My problem is I'm not sure how to incorporate the other two sorts requested. I fear that if I replicate what I've listed it will over write the previous sorts.

I also attempted to use the menu sort function but because the data starts on row 9 of the spreadsheet I'm trying to sort I was having trouble just using the column the menu sort was asking for because the header of this worksheet contains merged cells at the top.

The sorts, in requested order, are as follows: G9, H9 and L9. The associated data is A9:S200.

Any help is appreciated, thanks!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try :

Code:
    Range("A9:S200").Select
    Selection.Sort Key1:=Range("G9"), Order1:=xlAscending, Key2:=Range("H9") _
        , Order2:=xlAscending, Key3:=Range("L9"), Order3:=xlAscending, Header:= _
        xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
        xlSortNormal
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,693
Members
452,938
Latest member
babeneker

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