Info

Sub CustomSort()

1 add the custom list to Custom Lists Application.AddCustomList ListArray:=Range("I1:I5")

' get the list number nIndex = Application.GetCustomListNum(Range("I1:I5").Value)

' Now, we could sort a range with the custom list. 1 Note, we should use nIndex + 1 as the custom list number here, ' for the first one is Normal order

Range("A2:C16").Sort Key1:=Range("B2"), Order1:=xlAscending, _

Header:=xlNo, Orientation:=xlSortColumns, OrderCustom:=nIndex + 1 Range("A2:C16").Sort Key1:=Range("A2"), Order1:=xlAscending, _

Header:=xlNo, Orientation:=xlSortColumns

' At the end, we should remove this custom list... Application.DeleteCustomList nIndex End Sub

0 0

Post a comment