How to Use the SORT Function in Excel
SORT creates a live sorted copy of a range in Excel. Use it for dashboards, invoice lists, project reports, and clean review views.
Reviewed by Griddy
Updated for current Excel and Google Sheets workflows, with examples chosen to map back to real spreadsheet tasks rather than abstract formula syntax.
SORT returns a sorted copy of a range. It does not rearrange the original data. Instead, it spills a new sorted view into nearby cells.
That makes it useful for dashboards and reports where the source table should stay untouched, but the review view needs to show highest value, earliest due date, or newest row first.
The syntax
=SORT(array, [sort_index], [sort_order], [by_col])- array - the range to sort
- [sort_index] - which column number inside the array to sort by
- [sort_order] -
1for ascending,-1for descending - [by_col] - use
TRUEto sort columns instead of rows; most sheets leave this blank
Example: sort invoices by due date
Suppose A2:F100 contains invoices:
- column A: invoice number
- column B: client
- column C: status
- column D: amount
- column E: due date
- column F: owner
To create a live view sorted by due date, use:
=SORT(A2:F100, 5, 1)The 5 means "sort by the fifth column in the selected range," which is due date. The 1 means ascending, so the earliest due dates appear first.
Sort largest amounts first
To sort the same invoice table by amount from largest to smallest:
=SORT(A2:F100, 4, -1)The original table stays where it is. The formula output updates automatically when rows in the source range change.
⚠ WATCH OUT
#SPILL! error.SORT vs manual sorting
Manual sorting changes the source table. That can be fine for one-off cleanup, but it is risky in a working model where other formulas, comments, or review views depend on the original order.
SORT is better when you want a repeatable view:
- overdue invoices by due date
- largest deals by value
- tasks by priority
- expenses by amount
- clients by next follow-up date
The source data can remain an ordinary entry table while the SORT formula powers the review area.
When to use SORTBY instead
SORT works best when the sort column is inside the same range. If you need to sort by a separate helper column, or sort by several fields at once, use SORTBY.
For example, sort a table by due date ascending, then amount descending:
=SORTBY(A2:F100, E2:E100, 1, D2:D100, -1)That is often easier to read than trying to force several rules into a single SORT formula.
Common issues
| Issue | Cause | Fix |
|---|---|---|
#SPILL! | Cells are blocking the output | Clear the destination area |
| Wrong column sorted | sort_index counts inside the selected array | Count from the first column in array, not from column A |
| Header row appears in the results | Header was included in the array | Start the array at the first data row |
| Need multiple sort rules | SORT is too limited for the job | Use SORTBY |
The Griddy way
Sorted report views are useful, but they are easy to break when columns move.
"Create a live view of unpaid invoices sorted by due date, with the largest overdue amounts at the top"
Griddy can build the sorted view from your current sheet and adjust the formula around your actual columns.
Skip the manual work
Describe it. Griddy does it.
Instead of writing this formula yourself, just tell Griddy what you need in plain English. Works in Excel and Google Sheets.