Dynamic arrays
SORTBY
Sorts by other columns.
Syntax
SORTBY(array, by_array1, [sort_order1], …)Example: =SORTBY(A2:A100,C2:C100,-1)
Available in: Excel 2021+, Microsoft 365
Try it
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in F2: =SORTBY(B2:B7,C2:C7,-1)
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Region | Product | Units | Price | Result | |
| 2 | East | Pen | 120 | 2.5 | Pen | |
| 3 | West | Pen | 80 | 2.5 | Pen | |
| 4 | East | Book | 45 | 12 | Book | |
| 5 | North | Book | 60 | 12 | Book | |
| 6 | West | Lamp | 30 | 25 | Lamp | |
| 7 | East | Lamp | 15 | 25 | Lamp |
Result in F2: Pen