VBA 2-Level Sort

flynavy

New Member
Joined
Mar 18, 2015
Messages
43
I'm looking for a very simple, straightforward, 2-level sort (VBA) of one sheet in a workbook. I'm a mid-level VBA coder (just started 6 months ago). I have done many sorts in VBA, and many 2-level sorts using Excel without VBA. I'm just looking for something elegantly simple using VBA (best practice). Let's say my sheet is A1:D100, and I want to sort ascending by column "A" first, and then by column "C", both ascending, and no headers.
I've seen many suggestions of many different forums, but I'm looking for, as I said, one that is "elegantly simple".
Thanks in advance for any help.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Code:
Range("A1:D100").Sort _
        key1:=Range("A1"), order1:=xlAscending, _
        Header:=xlNo, DataOption1:=xlSortTextAsNumbers, _
        MatchCase:=False, Orientation:=xlTopToBottom

        key2:=Range("C1"), order1:=xlAscending, _
        Header:=xlNo, DataOption1:=xlSortTextAsNumbers, _

        MatchCase:=False, Orientation:=xlTopToBottom
 
Upvote 0
Try
Code:
Range("A1:D100").Sort Key1:=Range("A1"), Order1:=xlAscending, _
                      Key2:=Range("C1"), Order2:=xlAscending, _
                      Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
                      DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
 
Upvote 0

Forum statistics

Threads
1,217,123
Messages
6,134,761
Members
449,888
Latest member
webarnes99

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