Sort data largest to smallest in a row
How to sort data from largest to smallest 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 Largest to Smallest 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 Largest to Smallest from the Order drop down menu. 11. Click OK. |
12. This image represents the result of sorting the selected data from largest to smallest. |
Sub Sort_Largest_to_Smallest()
'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 largest to smallest in row 2
Rng.Sort Key1:=Range("2:2"), Order1:=xlDescending
Rng.Sort Key1:=Range("2:2"), Order1:=xlDescending
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 largest to smallest 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 largest to smallest 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 largest to smallest 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 largest to smallest 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 largest to smallest 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 largest to smallest number in a row using Excel and VBA methods.
Excel Method: This tutorial provides one example on how to sort data from largest to smallest, 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 largest to smallest, in a row.