Sort Each Column

D

DukeDevil

I have 250 columns which i need to sort individually - does anyone know
of some code that will sort each column in ascending order. The columns
are all independent. HELP PLEASE
 
C

CLR

Of course, try this first on a copy of your data............

Sub SortColumnsIndvidually()
'Sorts each column individually, ascending
'starting in Row 1
'change Cells(1.... to Cells(2....in all 4 places to start with Row 2
Dim lastcol As Long, i As Long
lastcol = Cells(1, 256).End(xlToLeft).Column
For i = lastcol To 1 Step -1
If IsNumeric(Cells(1, i)) Then
Cells(1, i).EntireColumn.Select
Application.CutCopyMode = False
Selection.Sort Key1:=Cells(1, i), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End If
Next i
End Sub

hth
Vaya con Dios,
Chuck, CABGx3
 
E

Excelenator

Assuming your data begins in the firts row and the columns ru
consecutively from A to the end of your data (i.e. no blank columns
this should do the trick


Code
-------------------
Sub ColSort()
Application.ScreenUpdating = False
Dim i As Integer

For i = 1 To WorksheetFunction.CountA(Range("1:1"))
Range(Cells(1, i), Cells(1, i)).EntireColumn.Select
Selection.Sort Key1:=Cells(1, i), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next i
Application.ScreenUpdating = True
End Su
 
Top