Custom Sort Order : Worksheet Sort « Excel « VBA / Excel / Access / Word






Custom Sort Order

 
Sub CustomSort()
    Application.AddCustomList ListArray:=Range("I1:I5")
    nIndex = Application.GetCustomListNum(Range("I1:I5").Value)
    Range("A2:C16").Sort Key1:=Range("B2"), Order1:=xlAscending, _
                            Header:=xlNo, Orientation:=xlSortColumns, _
                            OrderCustom:=nIndex + 1
    Application.DeleteCustomList nIndex
End Sub

 








Related examples in the same category

1.Sort fields