Have you ever wondered how you can horizontally sort data in Excel? I mean, sorting columns the way you sort rows. Want to know the best part?
So today, in this post, I’d like to share with you simple steps to horizontally sort data. And apart from this, I’d also like to share a simple tweak that you can do to sort columns in the custom order.
Note: It’s one of those Excel Tips that can help to get better at Basic Excel Skills.
Steps to Sort Columns in Excel
- First of all, select the data you want to sort. Leave out the column with the row labels, or it will be sorted along with the data.

- Go to Data Tab → Sort & Filter → click the Sort button. Now, you will get a pop-up window.

- You can also press Alt → A → S → S (one key after another) to open the Sort window.
- Click the Options button → select “Sort left to right” & click OK.

- Now, select the row on the basis of which you want to sort your data & click OK.

Congratulations! You have horizontally sorted your data.

With Excel tables, you are not able to use this technique, as a table can only be sorted top to bottom. Convert the table to a range first (Table Design → Convert to Range).
[Custom Order] Horizontal Sorting
In real life, there is more need to sort your columns in a custom order rather than using an alphabetic order. Follow these simple steps.
- Add a temporary heading row at the top of your data set & use numbers to create a custom order.

- Now, open your sorting window.
- And, sort columns by using your temporary row as a base.
- After that, just delete the temporary heading row.
If you sort by names like months or weekdays, you don’t need a helper row: in the Sort window, choose Order → Custom List and pick the list (or type your own order).
Sort Horizontally with a Formula
In Microsoft 365 and Excel 2021 or later, the SORT function can sort columns too. Set its last argument (by_col) to TRUE. The following formula sorts the data in B1:F2 left to right by the values in row 1 and spills the sorted result:
=SORT(B1:F2,1,1,TRUE)
Use -1 as the third argument to sort largest to smallest. With SORTBY, you can sort by any row of the data, like row 2:
=SORTBY(B1:F2,B2:F2,-1)
Unlike the Sort window, the formula keeps the original data as it is, and the result updates when the data changes.
Frequently Asked Questions
Why is the Sort left to right option greyed out?
You are sorting an Excel table. Tables only sort top to bottom, so convert it to a range or use the SORT formula.
Why did my row labels move when sorting left to right?
The label column was part of the selection. Select only the data columns before you open the Sort window.
Can I sort left to right by more than one row?
Yes. In the Sort window, click Add Level and pick a second row to sort by when the first row has the same values.
You seem to know a lot about excel. Can you help with this one? I rarely have a header row and want to simply select the range (usually 4-5 columns and anywhere from 5 to 30 rows) and use the a-z (or z-a) button to sort against the 1st column.
Now for the problem – more than half of the time, excel assumes that the first row is a header row and will not sort it with the rest. I realize I can go to the sort dialog box and un-check the “my data has headers” option. BUT, is there any way to permanently disable the automatic header row option? For the few times I sort with headers, it would be much more convenient to turn on the header row than it is to turn it off dozens of times a day.
Very informative. Thanks a lot, Puneet.
Hi Puneet,
I have not used this technique before .
I have always just moved columns one by way,
Your technique will be far better
Very Useful tip, Thank you
Thanks Brother! Too helpful on daily Job
I’m so glad you liked it. 🙂
Thanks Puneet , I was unaware of these tips. I really like the Custom Sort concept
I’m so glad you liked it. 🙂
Great! Very useful, thanks so much.
You’re welcome. 🙂
The key board shortcut to bring Sort dialog box can also be “ALT+D, S
@prabhaspanda:disqus Great