View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
merjet merjet is offline
external usenet poster
 
Posts: 812
Default Sorting Multiple Columns in a single operation?

The following does 4 columns and assumes the same number of rows in
each column. You can easily modify it to suit.

Sub Macro1()
Dim iEnd As Integer
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
iEnd = ws.Range("A1").End(xlDown).Row
For iCol = 1 To 4
ws.Range(Cells(1, iCol), Cells(iEnd, iCol)).Sort Key1:=Cells(2,
iCol), _
Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next iCol
End Sub

Hth,
Merjet