Sort fields : Worksheet Sort « Excel « VBA / Excel / Access / Word






Sort fields

 

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
 








Related examples in the same category

1.Custom Sort Order