Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Alphabetize Columns
I'm looking to put columns in alphabetical order based upon their
content in a given row. This works, but it seems to be rather inefficient. Is there a better way of doing this? Sub AlphaColumns() rw = 1 cStart = 1 cEnd = 10 For i = cStart To cEnd For j = i To cEnd If UCase(Cells(rw, i).Value) UCase(Cells(rw, j).Value) Then Cells(1, i).EntireColumn.Select Selection.Cut Cells(1, j + 1).EntireColumn.Select Selection.Insert Shift:=xlToRight i = Application.WorksheetFunction.Max(cStart, i - 1) End If Next j Next i End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Alphabetize Columns
Sub AlphaColumns()
rw = 1 cStart = 1 cEnd = 10 Set SortRange = Range(Cells(rw, cStart), Cells(rw, cEnd)) SortRange.Sort _ Key1:=Cells(rw, cStart), _ Order1:=xlAscending, _ header:=xlNo, _ Orientation:=xlLeftToRight End Sub " wrote: I'm looking to put columns in alphabetical order based upon their content in a given row. This works, but it seems to be rather inefficient. Is there a better way of doing this? Sub AlphaColumns() rw = 1 cStart = 1 cEnd = 10 For i = cStart To cEnd For j = i To cEnd If UCase(Cells(rw, i).Value) UCase(Cells(rw, j).Value) Then Cells(1, i).EntireColumn.Select Selection.Cut Cells(1, j + 1).EntireColumn.Select Selection.Insert Shift:=xlToRight i = Application.WorksheetFunction.Max(cStart, i - 1) End If Next j Next i End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Alphabetize Columns
Cells.Sort Key1:=Rows(rw), Order1:=xlAscending, Orientation:=xlLeftToRight
-- Jim Cone Portland, Oregon USA wrote in message I'm looking to put columns in alphabetical order based upon their content in a given row. This works, but it seems to be rather inefficient. Is there a better way of doing this? Sub AlphaColumns() rw = 1 cStart = 1 cEnd = 10 For i = cStart To cEnd For j = i To cEnd If UCase(Cells(rw, i).Value) UCase(Cells(rw, j).Value) Then Cells(1, i).EntireColumn.Select Selection.Cut Cells(1, j + 1).EntireColumn.Select Selection.Insert Shift:=xlToRight i = Application.WorksheetFunction.Max(cStart, i - 1) End If Next j Next i End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to alphabetize 8 columns as one? | Excel Discussion (Misc queries) | |||
Alphabetize in multiple columns | Excel Discussion (Misc queries) | |||
alphabetize | Excel Discussion (Misc queries) | |||
Can I alphabetize the info in my columns? | New Users to Excel | |||
Alphabetize? | Excel Discussion (Misc queries) |