Sorting 3 columns in Excel using VBA.

Hi

im trying to sort a 3 columns in excel using VBA. I was able to sort the first but when its time to sort the second the first sort is disregarded.

Please help.


PSD


Answer this question

Sorting 3 columns in Excel using VBA.

  • John Cherian

    Use the code similar to the one below

    Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("B1") _
            , Order2:=xlAscending, Key3:=Range("C1"), Order3:=xlAscending, Header:= _
            xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

    This was done on a selection

    However, you can use Range to sort


  • Sorting 3 columns in Excel using VBA.