sorting columns at the same time but independently of each other

C

curtc.

Is their a function or short macro that will sort columns by alpha but will
do all columns on the sheet at the same time and independently of the data in
the other columns?
Example:
A B C
1 fred john james
2 albert zack chris
3 bill curt mike

Updated:
A B C
1 albert curt chris
2 bill john james
3 fred zack mike
 
R

Roger Govier

Hi Curt

try the following macro

Sub SortColsIndependently()
Dim i As Long, lc As Long
lc = Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To lc
Columns(i).Sort Key1:=Cells(1, i), Order1:=xlAscending
Next i
End Sub

Copy the Code above
Alt+F11 to invoke the VB Editor
Insert>Module
Paste code into white pane that appears
Alt+F11 to return to Excel

To use
Alt+F8 to bring up Macros
Highlight the macro name
Run
 
C

curtc.

Thanks Roger. It works great for sorting multi columns on the same sheet, but
yet independently. Curt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top