VBA Code - Sort by Custom List Reference

Status
Not open for further replies.

tlc53

Active Member
Joined
Jul 26, 2018
Messages
399
Hi there,

I am trying to sort my data which is located under headings A52:K52 by the account number order, as stipulated in cells K21:K35.

This is my attempt but it is possible I'm way off the mark. Can anyone see how I can get this working please?

I don't want to refer to a particular sheet, it just needs to run on the active sheet.

Thank you!!

Code:
Sub CustomSort()


    Selection.CurrentRegion.Select
    Application.AddCustomList Selection:=Range("K21:K35")
    Sort.SortFields.Clear
    Sort.SortFields.Add2 Key:=Range("K53:K100000"), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
        Range("K21:K35"), DataOption:=xlSortNormal
    Sort.ActiveSheet
        .SetRange Range("A52:K100000")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply


End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi,

Since you have added your Custom List to all available lists ... you could test following modification:

Code:
CustomOrder:=Application.CustomListCount + 1

Hope this will help
 
Upvote 0
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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