# How to sort columns left to right with a formula in Excel

Set SORT's fourth argument, by_col, to TRUE: `=SORT(B1:F2,2,-1,TRUE)` sorts the columns by the values in row 2, largest first.

**Excel:** `=SORT(B1:F2,2,-1,TRUE)` (Excel 2021, 2024 and Microsoft 365)

**Google Sheets:** `=TRANSPOSE(SORT(TRANSPOSE(B1:F2),2,FALSE))`

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- |
| Region | North | South | East | West | Central |
| Q3 sales | 48200 | 61750 | 57300 | 39800 | 52100 |
|  |  |  |  |  |  |
| Sorted |  |  |  |  |  |

Formula in B4: `=SORT(B1:F2,2,-1,TRUE)`

Result (spills 2 × 5): South, East, Central, North, West; $61,750, $57,300, $52,100, $48,200, $39,800

## How it works

SORT normally reorders rows. With by_col set to TRUE it reorders columns instead, and the sort index `2` now means the second row of the range. Each region stays with its sales figure.

Google Sheets' SORT only sorts rows, so the Sheets version turns the range on its side with TRANSPOSE, sorts it, and turns it back.

## Other ways

- `=TRANSPOSE(SORT(TRANSPOSE(B1:F2),2,-1))`: The transpose trick works in Excel too, and is how you'd write it in Google Sheets.

## Common mistakes

- Without TRUE as the fourth argument, SORT treats the two rows as two records and sorts them as rows.
- Leave the label column (A) out of the range, or "Region" and "Q3 sales" get sorted along with the data.

## Questions

**How do I sort a row alphabetically?**

Sort by the first row instead: `=SORT(B1:F2,1,1,TRUE)`.

**Can I sort columns without a formula?**

Yes: Data > Sort > Options > Sort left to right. That rearranges the data itself, once.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/sort-columns-left-to-right
