Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Recognizing a Header Row when Sorting.

Recognizing a Header Row when Sorting

by Allen Wyatt
(last updated July 18, 2019)


There are two ways you can sort information in Excel: using the Sort Ascending and Sort Descending tools on the toolbar or by using the Sort dialog box. Using the toolbar tools allows you to do the sort more quickly, but Excel makes a few assumptions in the process.

First, Excel assumes that you want to sort only by the column of whatever cell you have selected. If you want to perform secondary and tertiary sorts on more than one column (or row), you need to use the Sort dialog box.

The second assumption affects exactly what Excel sorts. If you have a single cell selected, Excel extends the selection to select a range (much like pressing Ctrl+Shift+8) bounded by one or more blank columns and rows. It then examines the first row in the selected range to determine if it contains header information or not.

This is where sorting with the toolbar tools can become tricky—your header (assuming you have one) must meet some rather strict guidelines in order for Excel to recognize it as a header. For instance, if there are any blank cells in the header row, Excel may think it isn't a header. Likewise, if the header row is formatted the same as the other rows in the data range, then it may not recognize it. As well, if your data table consists entirely of text and your header row contains nothing but text, Excel will—virtually all the time—fail to recognize the header row. (The row looks just like another data row to Excel.)

Only after selecting the range and determining if there is a header row will Excel do the actual sorting. How pleased you are with the results depends on whether Excel got both the range selection and the header row determination right. For instance, if Excel doesn't think you have a header row, and you do, then your header is sorted into the body of the data; this is generally a bad thing.

To make sure that your data range is recognized correctly, use the Ctrl+Shift+8 shortcut to see what Excel selects; this is what will be sorted. If it doesn't match your expectations, then you need to either modify the character of the data in your table, or you need to select the data range before using the Sort dialog box.

To make sure that your heading is recognized correctly, use the Ctrl+Shift+8 shortcut to select the data range, then look at the first row. If your header has blank cells among those selected in the first row, or the first row is formatted just like the second row, or you have more than one header row selected, then Excel assumes you have no header row at all. To correct this, make changes in your header row to make sure it is recognized properly by Excel.

Finally, all bets could be off if your data table uses multi-row headers. Excel has a hard time recognizing them. You compound the problem when you expect it to include blank rows in that header; it just can't do it automatically. You can, however, simply select all the rows you want to sort before doing the sort. In other words, be specific in what you want Excel to sort; don't let Excel make the assumptions for you.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2586) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Recognizing a Header Row when Sorting.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Using Object Anchors

An object anchor is used to signify the point at which an object is inserted into a document. If you want to see these ...

Discover More

Copying Styles

If you use styles in your documents, you know it can take a good investment of time to get them just the way you want. ...

Discover More

Adding Ampersands in Headers and Footers

Add an ampersand to the text in a header or footer and you may be surprised that the ampersand disappears on your ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Sorting by Colors

Need to sort your data based on the color of the cell? Excel doesn't include this capability, but you can still do the ...

Discover More

Alphabetizing Worksheet Tabs

As yo get more and more worksheets into a workbook, you'll find yourself moving them around into different sequences. You ...

Discover More

Sorting Dates by Month

Sorting by dates is easy, and you end up with a list that is in chronological order. However, things become a bit more ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four less than 7?

2018-06-19 01:25:29


Simply BOLD the header row, as mentioned in this solution, and you will be good to go:

BTW, I didn't fine the cntrl + shift + 8 as the right way to find how much data would excel sort. The header row (even when recognized) was included in this operation.

2018-02-25 03:53:47


Score! Yet another Microsoft inept [non]explanation clarified. Your "strict guidelines" saved me.

Thanks for what you do. A shame that Microsoft designers are too lame to do it in the first place.

2017-11-24 16:52:32


I just want to say thank you for helping with how to freeze the header and make it sortable across rows without moving. I spent an hour trying to figure out what went wrong. I had two columns I had added without titles...and excel stopped recognizing the row as a header because of it. THANK YOU!

2017-04-24 18:41:08


I tend to get the opposite problem - Excel incorrectly assuming the first row of my selection is a header row and failing to sort it with the rest of the data. What's the fix for this?

2016-12-09 07:52:35


Alternative option: use google. Google recognizes a multi-row header and doesn't require you to jump through any hoops. It just works.

2016-10-17 14:15:25

Jonathan Sanders

Thank you Jay! That fixed a very common and frustrating problem for me.

2016-08-10 05:16:53

Bruce L

Rach: If Jay's solution fixed your problem that's great, but it also means you had a different problem to the one discussed above.

2016-08-09 17:08:58


Jay had the best answer and was the easiest to follow. The description above is just confusing at best...

2016-03-20 13:23:54


I've had this issue and searched in vain for an answer. But I have a possible solution. If you're sure your headings fit the specifications required by Excel - per the prior explanations - and your data is still sorting the headers into the rest of the data - it could be that Excel believes there's something in an adjacent column. In my case I've deleted the column to the right of my data, inserted a new blank column and that still didn't solve the issue. BUT, copying the database - and only the actual data set - to a new sheet worked. Excel sensed the header row and now sorts correctly without my having to use the Data/Sort menu.

2015-11-10 17:38:27


"To correct this, make changes in your header row to make sure it is recognized properly by Excel."

This is a fairly long winded explanation of why your header row sorts in with the rest of your data. The above answer is extremely inarticulate and makes this a relatively frustrating article...."let me explain in detail why your problem exists. The answer is: fix it, stupid"

2015-08-21 11:39:59


Insterting a blank line below headers and
Ctrl+Shift+8 supplies most of my sorting needs. Thanks!

2015-08-06 12:50:00


Can we make excel always have the box "my data has headers" checked off? I have to always check that.

2015-05-10 23:28:58

Joe Hardy

To echo Diane, thanks Jay!

2015-04-18 11:58:31



Thanks for the tip! That saved me a lot of time. Your instructions were simple and exact.

2015-01-14 19:44:22


I use 'Excel for Mac 2011'.

How do I sort a column AND still retain the #1 heading 'row' intact at the top and not be included in the sort?

NB: I need to globally select the WHOLE column - as I have hundreds and hundreds of rows and I don't want to have to selectively select the data in the column ie by leaving out the heading).

I am unable to get the above solutions working in Excel for Mac.

Solution will be greatly appreciated.

2015-01-04 10:24:02

Bruce L

I think this page is destined to collect comments from well-meaning people trying to help but who either haven't really read the article or don't understand the reasoning behind it.

2015-01-02 17:16:06


For Excel 2010:
1. Click the "triangle" to the left of Column Label "A" and right above Row Label "1" to select all of you data (or "CTRL + A" to select all)
2. Click the "DATA" tab
3. Click the "SORT" button
4. Click to check the checkbox on the top right-hand corner (right below the close/X button) that says "My data has headers".
5. Then select the column(s) you would like to sort by and click "OK".

Provided you have your "header/label" row at the very top of all your data, excel will almost always sort your data range below the labels and keep your label/header row at the top.

2014-12-02 05:32:38

Bruce L

Melly I think everyone knows that - this article is about getting Excel to automatically recognise column headers when sorting without using the dialog.

2014-12-01 19:34:31


Click on the Data tab, under the Sort & Filter Group click on Sort. The Sort dialog box appears. In the top right hand corner of the box - check "My data has headers" box. The range to be sorted is highlighted. Click on OK to confirm and your data will sort with the headers intact.

2014-10-27 01:19:16


I assume the "no real solution" comment was something like "how can you force Excel to recognize that my header exists?" *I* do that by inserting a blank row between the bottom of my header and the rows that contain the data I'm sorting. Excel will always hit the blank and stop, unless you selected through the blank into the header.

2014-09-24 05:22:39


You didn't find an answer to your exact problem so you chose to criticise the person who went to the effort of preparing fairly comprehensive general help on the subject? You need to be a bit less ungrateful.

2014-09-23 11:42:10


You really need to organize your information better. This took way to long to read through, only to find out you offer no real solution.

2014-08-29 12:00:14


I am sorting one column by alphabetizing names. That part is done. Now I'd like to total the amounts in an adjacent column for each name. How do I do that?

2014-08-29 10:51:40


gffsdg, you just got served!!

2014-07-09 16:52:35


It displays after 45 seconds. It is not selling anything, but offering you a chance to subscribe to the free weekly ExcelTips newsletter.

If you don't want to, fine. Just close the window and, if you have cookies enabled on your system, you won't see the subscription offer again for six months.

Of course, all this is explained in that window, in a bit more detail.


2014-07-09 16:43:53


What's with the annoying pop-up message that appears after a few seconds? I am extra unlikely to buy any product offered in a pop-up message?

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.