Sorting Huge Lists

Written by Allen Wyatt (last updated October 24, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


In an office environment, it is not uncommon to load huge lists of data into Excel that have been generated by programs different than Excel. You can then use Excel to massage and analyze the data to suit your needs.

One common task is to sort the data list. If you sort your list and then find out that the sort wasn't don't properly, this can be very disconcerting. There are three possible reasons that a list won't sort properly.

First, the list could include blank rows or columns. If this is the case, then you can only sort the list properly by selecting the entire list before doing the sort. When you rely upon Excel to select the list automatically, it stops at blank rows and columns, which of course affects your sorting.

Second, the list could be so large that you just don't have enough memory to perform a complete sort of your data. The only solution for this is to sort the list on a different machine, or add more memory to your computer.

Third, the list could contain numbers that are formatted as text. Either the original file contained characters that Excel cannot parse as numbers (such as a minus sign to the right of a number), or Excel's import filter just decided to misinterpret the data it was reading.

In reality, it is this third possibility that is the most likely when importing information into Excel. Let's say that you sort a list based on a particular column, and the list seems to "start over" again in the middle. For instance, it sorts from 1 to 1000, and then starts again at 1. This is a dead give away that the second set of values (the second 1 through 1000 range) consist of cells formatted as text rather than as numbers. Why? Because text is always sorted to appear after regular numbers. To convert the text values into numbers, try these steps:

  1. In a blank cell, enter the number 1.
  2. Select the cell and press Ctrl+C. This copies the cell to the Clipboard.
  3. Select the cells that you think contain numbers formatted as text.
  4. Choose Paste Special from the Edit menu. Excel displays the Paste Special dialog box. (See Figure 1.)
  5. Figure 1. The Paste Special dialog box.

  6. Make sure the Multiply radio button is selected.
  7. Click on OK.
  8. Delete the cell you created in step 1.

When completed, any numbers formatted as text are converted to their numeric equivalents. You can then try to resort the data list.

You should note that the above steps won't work if the text-formatted values imported into Excel have any text, other than a space, in them. Some programs add the ASCII character 160. This character is sometimes called a "sticky-space." It looks like a space, but doesn't act like one. The extraneous text must be removed before you can make the text into numbers. You can, of course, use the Find and Replace feature of Excel to get rid of any non-numeric characters in a range of cells.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2922) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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

Turning the Legend On and Off

When you create a chart in Excel, the program may automatically add a legend that explains the contents of the chart. In ...

Discover More

Calculating Time Differences between Two Machines

Want to know how much of a time difference there is between your machine and a different machine? This tip provides some ...

Discover More

Error Creating Event Handlers

If you are getting an error when you try to create an event handler, it could be related to a long-known bug in Excel. ...

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)

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

Too Many Formats when Sorting

Sorting is one of the basic operations done in a worksheet. If your sorting won't work and you instead get an error ...

Discover More

Determining Sorting Criteria

If you need to know how a range of data is sorted, the task is not as easy as you might at first think. This tip examines ...

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?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


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