Sort data smallest to largest in a row
How to sort data from smallest to largest number in a row using Excel and VBA methods
Select data > Home tab > Sort & Filter > Custom Sort > Options > Select Sort left to right > OK > Select the Row by which to sort > Select which to Sort on > Select Smallest to Largest Order > OK
1. Select the range that captures the data you want to sort. |
2. Select the Home tab. |
3. Click on Sort & Filter in the Editing group. 4. Click on Custom Sort. |
5. Click on Options |
6. Select Sort left to right 7. Click OK |
8. Select the Row by which you want to sort by. Note: in this example we are sorting by a row that captures the product quantity and is titled Quantity. 9. Select the Sort on type. Note: in this example we are sorting by cell values. 10. Select Smallest to Largest from the Order drop down menu. 11. Click OK. |
12. This image represents the result of sorting the selected data from smallest to largest. |
Sub Sort_Smallest_to_Largest()
'declare a variables
Dim ws As Worksheet
Dim Rng As Range
Dim ws As Worksheet
Dim Rng As Range
Set ws = Worksheets("Sheet1")
Set Rng = ws.Range("C2:I3")
Set Rng = ws.Range("C2:I3")
'sort data from smallest to largest in row 2
Rng.Sort Key1:=Range("2:2"), Order1:=xlAscending
Rng.Sort Key1:=Range("2:2"), Order1:=xlAscending
End Sub
PREREQUISITES
Worksheet Name: Have a worksheet named Sheet1.
Data Range: In this example the data is captured in range ("C2:I3"). This range does not include headings.
Row Order: In this example the data is being sorted from smallest to largest by row 2, which is represented by range reference ("2:2").
Worksheet Name: Have a worksheet named Sheet1.
Data Range: In this example the data is captured in range ("C2:I3"). This range does not include headings.
Row Order: In this example the data is being sorted from smallest to largest by row 2, which is represented by range reference ("2:2").
ADJUSTABLE PARAMETERS
Worksheet Name: Select the worksheet that captures the data that you want sort by changing the Sheet1 worksheet name.
Data Range: Select the data range that you want to sort by changing the range reference("C2:I3").
Row Order: Select the row which you want to sort from smallest to largest by changing the range reference ("2:2") to any row that is within the specified range.
Worksheet Name: Select the worksheet that captures the data that you want sort by changing the Sheet1 worksheet name.
Data Range: Select the data range that you want to sort by changing the range reference("C2:I3").
Row Order: Select the row which you want to sort from smallest to largest by changing the range reference ("2:2") to any row that is within the specified range.
ADDITIONAL NOTES
Note 1: This VBA code assumes that the selected data range does not include headings.
Note 1: This VBA code assumes that the selected data range does not include headings.
EXPLANATION
This tutorial explains and provides step by step instructions on how to sort data from a smallest to largest number in a row using Excel and VBA methods.
This tutorial explains and provides step by step instructions on how to sort data from a smallest to largest number in a row using Excel and VBA methods.
Excel Method: This tutorial provides one example on how to sort data from smallest to largest, in a row. This method requires changing the sort options, to sort from left to right instead of top to bottom.
VBA Method: This tutorial provides one VBA example on how to sort data from smallest to largest, in a row.