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!!
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