Hi,
What is preventing the below custom sort from running?
To satisfy object requirements, line 4 converts cells to text values yet the error persists. Otherwise the code looks fine to me but documentation/threads have not identified the cause of the error in this case.
What is preventing the below custom sort from running?
VBA Code:
Dim keyRange As Variant
Dim sortNum As Long
Dim RowsSorted As Long: RowsSorted = Worksheets("[tab]").Cells(Worksheets("[tab]").Rows.Count, 5).End(xlUp).Row
Worksheets("[tab]").Range("A2:A" & RowsSorted).NumberFormat = "@"
keyRange = ActiveWorkbook.Worksheets("[tab]").Cells.Range("A2:A" & RowsSorted).Value
Application.AddCustomList ListArray:=keyRange
sortNum = Application.CustomListCount
ActiveWorkbook.Worksheets("[LEFT][SIZE=4][FONT=Segoe UI][COLOR=rgb(20, 20, 20)][tab][/COLOR][/FONT][/SIZE][/LEFT]").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("[LEFT][SIZE=4][FONT=Segoe UI][COLOR=rgb(20, 20, 20)][tab][/COLOR][/FONT][/SIZE][/LEFT]").Sort.SortFields.Add Key:=Range("G:K"), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:=sortNum, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("[LEFT][SIZE=4][FONT=Segoe UI][COLOR=rgb(20, 20, 20)][tab][/COLOR][/FONT][/SIZE][/LEFT]").Sort
.SetRange Range("A:K")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
To satisfy object requirements, line 4 converts cells to text values yet the error persists. Otherwise the code looks fine to me but documentation/threads have not identified the cause of the error in this case.