Preventing Jumbled Sorts

Written by Allen Wyatt (last updated April 22, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

Jenny has a large worksheet that she often needs to sort. Several times the data has gotten "jumbled" after a sort. Jenny wonders if there is a way other than manually selecting all the cells to be sorted to ensure that all the data is selected before Excel actually performs the sort.

The biggest thing you can do to prevent jumbled sorts is to remember how Excel "detects" the data you want to sort. Starting with the currently selected cell, Excel looks in all directions (up, down, left, and right) until it finds empty rows or columns. Once it finds the empty row or column, it figures it has found a boundary for the data you want sorted. Thus, if your data that you want sorted actually contains empty rows or columns, sorting will invariably mess up your data because Excel won't catch everything.

The first way around this is to select the rows and columns—all the data—that you want sorted before performing the sort. The better solution, though, is to make sure there are no empty rows or columns in your data—just delete them or place something in the row or column so Excel recognizes it as part of your data.

If your data is jumbled by the column headings moving around after sorting, then you need to make sure the headings are differentiated from the data in the table in some way. I like to make sure that they are bold and each cell is underlined. This has typically done the trick so that Excel automatically recognizes them as headings and not as data. Plus, if I include a heading in an otherwise empty column, that column is no longer empty and Excel recognizes it as part of the data to be sorted. (This helps alleviate the problem of blank columns discussed earlier.)

Another way to help prevent jumbled sorts is to define your data as a table. You do this by selecting the rows and columns that make up your data and then pressing Ctrl+T. Excel displays the Create Table dialog box, where you can verify that all of your data is selected. Click OK in the dialog box, and the table is created. When you choose to sort the table, all of the data—including any blank rows or columns in the table—is included in the sort.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (6285) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

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

Opening Documents in Print Layout View

If you have a Word 2003 document that always seems to open in reading layout mode, you may want to turn that "feature" ...

Discover More

Inserting Fields

Fields are used for a variety of dynamic purposes in a document. There are a couple of ways you can easily insert fields, ...

Discover More

Ignoring Special Characters when Double-Clicking

If a word contains a special character within it, Excel actually thinks the single word is two words. This tip examines ...

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)

Sorting Dates and Times

One of the strong features of Excel is its ability to sort information in a worksheet. When it doesn't sort information ...

Discover More

Incorrect Links after Sorting Hyperlinks

When you sort your data, you should always check to see if the sort was done correctly. What if sorting messes up ...

Discover More

Ignoring Selected Words when Sorting

If you use Excel to maintain a list of text strings (such as movie, book, or product titles), you may want the program to ...

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}] (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 six minus 4?

2023-04-22 05:40:46

Paul

You can check that Excel is recognising all the data in your data table by clicking in the data, holding down CTRL and tapping A. This will select all the data and only the data.

Alternatively, click in the data, click the the Sort and Filter button at the right-hand end of the Home tab and choose Custom Sort. This displays a dialog box where you can set your sort and tick the "My table has headers" box so Excel recognises the headings row. While the Custom Sort dialog box is displayed, on the worksheet Excel highlights all the data it will sort - the highlight should include all your data (apart from the headings) and nothing else.


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.