Dual Criteria Sort failing

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,570
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
My sort isn't working ...
Rich (BB code):
          With .Range("A13:R" & pl)
                .Sort key1:=.Range("R13"), order1:=xlAscending, Header:=xlNo, _
                    OrderCustom:=Application.CustomListCount + 1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
                .Sort key2:=.Range("F13"), order2:=xlAscending, Header:=xlNo, _
                    OrderCustom:=Application.CustomListCount + 1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption2:=xlSortNormal
            End With

The line in red is giving me a sort method of Range class failed".

Two things to note that may be problematic, and they in themselves are problems I don't know how to overcome if they are contributors to the error.
PL = 12, and there are no values in column F (but then again there are none in column R either and it passes that sort)
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
you said you have defined your var PL as your ending row number =12 is that the correct range
 
Upvote 1
Yes. PL in this case equals 12 because the dataset is empty. (Only two blank rows .. 12 and 13. If there was data, PL would be greater than 13.
The first sort criteria, similarly written, doesn't break with an error.
 
Upvote 0
It should be Key1 & Order1, not Key2 & order2
 
Upvote 1
Solution
Hmmmm, this is my bad. I don't think I've explained final expectation properly. Fluff, this was indeed the solution. I had originally started with that but changed it because the results were wrong. It turns out that I needed to switch the order of the sorts.

Thank you all.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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