I have VBA Code to sort the data on sheet ?Account Numbers? by Col C in the same order per sheet ?Unique? in Cell Z1 to Z5
When Runing the code, I get a run time error : Appllication Defined Error
.Range("A1:C" & Lr).Sort key1:=.Range("C2"), order1:=xlAscending, _
customOrder:=customOrder, MatchCase:=False, Header:=xlYes
My Full Code is
Sub Sort_ByType()
Dim Lr As Long
Dim customOrderRange As Range
Dim customOrder() As Variant
' Set the custom order range
Set customOrderRange = Sheets("Unique").Range("Z1:Z5")
' Read the custom order values into an array
customOrder = customOrderRange.Value
With Sheets("Account Numbers")
Lr = .Cells(.Rows.Count, "C").End(xlUp).Row
.Range("A1:C" & Lr).Sort key1:=.Range("C2"), order1:=xlAscending, _
customOrder:=customOrder, MatchCase:=False, Header:=xlYes
End With
End Sub
Kind Test & Amend my Code
I have also posted on https://www.mrexcel.com/board/thread...-sort.1240892/
Bookmarks