VBA/Excel/Access/Word/Excel/Worksheet Sort
Custom Sort Order
<source lang="vb">
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
</source>
Sort fields
<source lang="vb">
Sub Macro2()
range("A1:A4").Select ActiveWorkbook.Worksheets("Sheet1").sort.SortFields.clear ActiveWorkbook.Worksheets("Sheet1").sort.SortFields.add Key:=range("A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Sheet1").sort .SetRange range("A1:A4") .HEADER = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With
End Sub
</source>