sorting macro

  • Thread starter Thread starter GLeeds
  • Start date Start date
G

GLeeds

I need to sort on 8 cells in a row and on 1500+rows. I can do it one at a
time but I know there must be an easier way. Can ANYONE HELP?

C3:J3 I need these cells sorted and then down to C1532:J1532

I did create a macro to sort after I selected them but still one at a time.
Does it have to be a macro? I can edit a macro but don't really know how to
program them.
 
Yes, it has to be a macro. The following should do it. This macro loops
through all the entries in Column C, and in each row it sorts the values in
Columns C:J. HTH Otto
Sub SortRows()
Dim rColC As Range
Dim i As Range
Dim TheRow As Range
Dim RngToSort As Range
Set rColC = Range("C3", Range("C" & Rows.Count).End(xlUp))
Set TheRow = Range("C1:J1")
For Each i In rColC
Set RngToSort = TheRow.Offset(i.Row - 1)
RngToSort.Sort Key1:=Cells(i.Row, 3), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
Next i
End Sub
 
Sub sortcolumnsbyrow()
For i = 3 To Cells(Rows.Count, 3).End(xlUp).Row
Cells(i, 3).Resize(, 8).Sort Key1:=Cells(i, 3), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlLeftToRight
Next i
End Sub
 
Hi Otto,

Thank you for your reponse. I tried Don's first and it worked great.

Thanks again
 
Hi Don,


Thank you sooo much.. This works great. I was getting missed calcs in the
beginning but found I gave you some wrong info. The number of cells was 7 not
8 so one minor change and WOW. Works like a charm. It's great to have a
format like this for someone like me to get some fast easy answers.. Thank
you MS....

Thanks again....
 
Back
Top