Forum Home
Press F1
 
Thread ID: 81749 2007-08-06 03:40:00 Sorting a row in excel bpt2 (6653) Press F1
Post ID Timestamp Content User
576998 2007-08-06 03:40:00 I have a number of columns with numbers which I want to sort from small to large in each row. (The columns will therefore get mixed up which is fine) bpt2 (6653)
576999 2007-08-06 04:26:00 sort by accending?

linky office.microsoft.com

also the help in excel is quite good especially if allow excel access to the interweb
panther2 (11440)
577000 2007-08-06 04:32:00 Highlight that entire column, click on Data and click Sort. It should provide you with the options to sort the data in anyway you want. ronyville (10611)
577001 2007-08-06 05:43:00 I don't think that answers my question. I want to sort the following rows so that they all end up ascending from left to right. This will mix up the columns.
0 1 1 1 2
2 2 0 1 3
0 3 1 2 0
0 1 2 4 2
3 2 1 1 5
0 5 4 1 2
1 1 0 1 2
2 0 1 1 2
bpt2 (6653)
577002 2007-08-06 05:55:00 Found what I am after:
Sub Sortrows()
Dim rw As Range
If Selection.Columns.Count = 1 Then
MsgBox "your selection must involve more" _
& " than one cell or column"
Exit Sub
End If
For Each rw In Selection.Rows
rw.Sort key1:=rw, Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlLeftToRight
Next
End Sub

Thanks anyway.
bpt2 (6653)
1