![]() |
Sort Each Column
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 |
Sort Each Column
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 "DukeDevil" wrote: 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 |
Sort Each Column
Assuming your data begins in the firts row and the columns run 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 Sub -------------------- DukeDevil Wrote: 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 -- Excelenator ------------------------------------------------------------------------ Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768 View this thread: http://www.excelforum.com/showthread...hreadid=568034 |
All times are GMT +1. The time now is 03:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com