sort multiple rows left to right

  • Thread starter Thread starter Grog
  • Start date Start date
G

Grog

Hello,
I have a list of test questions and answers. Column A has the questio
and columns B to E have 4 answer choices. There are about 600 rows i
the list.

I would like to sort the 4 answers in each row alphabetically. Usin
excel's sort feature I would have to do this one row at a time. An
ideas on a macro that could do this quickly?

Thanks!

Gro
 
Change the xlAscending bit to xlDescending if you prefer it the other way:-


Sub SortRows()

Dim r As Long
Dim lrow As Long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
lrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row

'Make the r = 3 whatever the first row of data you want to sort on is.
'The Cells(r, 2) means your data starts in Col 2 or Col B - adjust as necessary
'The resize(1, 4) expands the range to 1 cell deep by 4 cells wide

For r = 3 To lrow
With Cells(r, 2).Resize(1, 4)
.Sort Key1:=Cells(r, 1), Order1:=xlAscending, Header:=xlGuess, _
Orientation:=xlLeftToRight, DataOption1:=xlSortNormal
End With
Next r

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
 
Back
Top