Preventing Jumbled Sorts

Written by Allen Wyatt (last updated May 24, 2021)
This tip applies to Excel 2007, 2010, 2013, and 2016


3

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, and 2016.

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

Removing a Subdocument from a Master Document

Just as you can add subdocuments to a master document, you can remove them. Doing so is relatively easy, and it doesn't ...

Discover More

Getting a Warning for Markup

Many people, when collaborating on a document with others, use the Track Changes feature to show the effects of their ...

Discover More

Selectively Changing Endnotes to Footnotes

Want to turn some (but not all) of your endnotes into footnotes. Rather than do it manually, you can apply the shortcut ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Sorting Serial Numbers by Their Trailing Characters

Sorting information in Excel is a common task. Sorting information that isn't in the primary order that you need can be a ...

Discover More

Controlling Sorting Order

When you sort information in a worksheet, you have control over the order in which that information is sorted. Here's a ...

Discover More

Sorting Decimal Values

Government and industrial organizations often use a numbering system that relies upon a number both before and after a ...

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 two more than 0?

2021-05-30 06:06:19

Philip

Converting to tables is something I try to avoid always, as it takes away a number of other functionality opportunities. An easy way to make sure your sorting works better (and e.g. your first row doesn't get jumbled up) is to do the sorting by applying autofilters (select the row with your header titles from first to last column, then activate the autofilter arrows by selecting "filter" from the DATA ribbon. Never had any issues doing it that way, and you don't have to go to converting your data to "tables"


2017-07-16 19:20:48

walter costello -

I use a numeric reference in Column A to regain control of the spread sheet should it become scrambled by sorting for whatever reason.


2017-07-16 10:48:19

Pete Zicari

I think your advice on sorting here is spot-on, and you prompt a question I hadn't thought of. I use Index(,match()) extensively to combine and filter columns of data. When I have finally compiled my project into a final table for the boss, I have found that sorting it can completely scramble the column. (This was in Excel 2011) Eventually I learned to paste a copy of the table as values into a table that the biss can sort to his heart's content. Is there a way to skip that step.


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.