Archive of Mr Excel Message Board
I have many coluns of numbers. I want to sort each data set in each column from smallest number to largest. How do I sort all the columns at once instead of highlighting each column one at a time and sorting?

| Check out our Excel VBA Resources | ||||
![]() |
![]() |
![]() |
![]() |
![]() |

Hi Sean
You may need a macro for this, so here is one.
To use it Push Alt+F11 and go to Insert>Module.
Paste in this code:
Sub MultiSort()
Dim Cols As Range, i As Integer
Set Cols = Selection
For i = 1 To Cols.Columns.Count
Cols.Columns(i).Sort Key1:=Cols.Columns(i).Cells(1, 1), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
Next i
End Sub
Push Alt+Q and save.
Select all your columns you want to sort (including headings) and push Alt+F8.
Click "MultiSort" then "Run"
Dave
OzGrid Business Applications
