Differentiating a Header Row

by Allen Wyatt
(last updated December 29, 2015)

6

Josiah knows that formatting changes to the first row of a list automatically clues Excel to the fact that the row is a header row so it won't be included in sorting. He wonders, though, what exactly Excel looks for when it determines that the first row of data is a header row. For example, just making the first row bold does not seem to be enough, so he wonders what it really takes.

Microsoft has not published the algorithm it uses to make this determination, but one can intuit the formatting differences that are necessary. A good indicator seems to be if the data in the first row is different than the data in subsequent rows. For instance, if a column contains dates, times, or numbers (and are formatted as dates, times, or numeric formats), but the first cell in the column contains text (and aren't formatted as a date, time, or number), then Excel can hazard a guess that the first row contains headers.

Another flag for Excel seems to be if your header row has borders turned on, whereas the rest of your cells do not. (I make it a point to always make the first row bold with a bottom border, and this seems to do the trick every time.)

You should note, however, that Excel doesn't do well with multi-row headers or blank cells in a single-row header. It only really recognizes, automatically, a single header row. If you have a multi-row header, select the data you want sorted before you sort it. If your header row contains blank cells, then Excel (for some reason) interprets the row as part of your data. Again, you'll want to select the actual rows to be sorted before actually sorting.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3828) applies to Microsoft Excel 2007, 2010, and 2013.

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. ...

MORE FROM ALLEN

Changing the Color Used to Denote Selected Cells

When entering data into a range of cells, the cell in which you are working appears in a different color than the other cells ...

Discover More

Returning Zero When a Referenced Cell is Blank

Reference a cell in a macro, and if that cell is blank Excel normally equates that to a zero value. What if you don't want ...

Discover More

Conditional Printing

If you need to make what Excel prints be based upon conditions in a worksheet, you'll love the information in this tip. There ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Underlining Text in Cells

Want a quick way to add some underlines to your cell values? It's easy using the tools on the Home tab of the ribbon.

Discover More

Defeating Automatic Date Parsing

Excel is continually trying to figure out what type of data is being stored in a cell. If it can interpret a value as a date, ...

Discover More

Problems with Custom Views

If you get an error when you try to use one of your custom views, it could be due to the protection you have applied to the ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. 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 five less than 5?

2016-01-05 11:29:12

Gary Lundblad

I seem to have problems if I delete columns, although not always. Usually I sort a range of data, and it recognizes the header rows correctly, but then I delete a column, select the same range, select sort, and it no longer recognizes the header row. What happened, and how can I get it to recognize it again?

I have tried making the text bold, italics, underlined, shaded, with a bottom border, and it still doesn't see it. Help!

Thank you!

Gary


2015-12-29 12:13:03

Neil

Often when I try to apply auto-filtering to a table with multiple headers by clicking a single cell in the table and choosing filter, it erroneously chooses the wrong headers. I get around this by selecting just the data I want to filter (including the desired header row) and then it knows which headers get the filter dropdowns.


2015-12-29 08:03:47

Barry Clermont

Great tip. I would suggest making sure you use a single row if you ever want to apply a pivot table or pull into Access.


2013-06-17 09:29:07

David Staudenmeir

I've personally never found the "my data contains headers" box unchecked by default, and so have never had to apply any kind of first row formatting, other than what I might normally do anyway, with the thought of applying that just to trigger the "header row" criteria.


2013-06-16 09:04:12

Tony

For me, the box always comes up so I simply confirm that "Yes, my data contains header rows".


2013-06-15 12:51:50

Jerry

Some of the dialog boxes for commands that operate on data ranges (such as Sort and Create Table) have a "My data contains headers" checkbox that you can turn on if Excel doesn't recognize the header row. But it's better to apply the formatting, as discussed in the tip, so you never have to remember to check the box!


This Site

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

Newest Tips
Subscribe

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.