# Sort left to right on five cells in a row, then next row

#### snowdrift

##### New Member
I have five numeric values that are are in no particular order going from left to right, like:

ROW 1: 5 15 19 10 25
ROW 2: 5 2 34 13 5
ROW 3: 15 19 16 1 13

I know how to sort these from left to right ascending on a row-by-row basis.

But... how can I sort multiple rows' worth of such data all at once, keeping each row's sort segrated from the other rows?

### Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I am trying to avoid using VB if possible. I did find this one solution:

http://www.mvps.org/dmcritchie/excel/sorting.htm

Sorting a selection by Rows, with each Row being independent of the other rows

The following is based on Tom Ogilvy's example but has been made a bit more generic to process a Selection instead of a specific Range. Example shows a single selection area, modified to distinguish rows.

Sub sortEachRow()
'based on Tom Ogilvy, 2001-03-24, Programming
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, _
MatchCase:=False, _
Orientation:=xlLeftToRight
Next
End Sub

If your data is in A1 to E1` then place these formulas in cells F1 to J1:

F1 =SMALL(\$A1:\$E1,1)
G1 =SMALL(\$A1:\$E1,2)
H1 =SMALL(\$A1:\$E1,3)
I1 =SMALL(\$A1:\$E1,4)
J1 =SMALL(\$A1:\$E1,5)

That works, Doug!

Thank you for your easy-to-implement solution! It worked great.

I appreciate the help.

Replies
1
Views
595
Replies
4
Views
264
Replies
15
Views
634
Replies
2
Views
151
Replies
4
Views
250

1,221,507
Messages
6,160,213
Members
451,630
Latest member
zxhathust

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Which adblocker are you using?

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back