To make Excel order numbers sort numerically instead of alphabetically, you must convert the cells from Text format to Number format. This is most quickly achieved by selecting the column, clicking the warning icon that appears next to the cells, and selecting Convert to Number, or by using the Text to Columns feature to force a data type change. When Excel treats numbers as text, it sorts them digit by digit (1, 10, 11, 2, 20), whereas numerical sorting treats the value as a whole (1, 2, 10, 11, 20).

What You'll Need

  • A computer with Microsoft Excel installed.
  • A dataset containing order numbers, IDs, or SKU numbers that are currently sorting incorrectly.
  • Administrative access to the spreadsheet to make formatting changes.

Step-by-Step

  1. Identify the Data Type: Look at your order number column. If you see small green triangles in the top-left corner of the cells, Excel has already flagged these as numbers stored as text. If you do not see the triangles, look at the Home tab in the Number group; if the dropdown says Text, your numbers are being treated as strings of characters.
  2. Method 1: The Error Warning Shortcut: Select all the cells in the order number column that need to be changed. A small yellow diamond warning icon will appear to the right of the first selected cell. Click this icon and select Convert to Number from the menu. This is the fastest way to fix a small to medium dataset.
  3. Method 2: Text to Columns (Best for Large Datasets): If the warning icon does not appear or you have thousands of rows, select the entire column by clicking the letter at the top. Go to the Data tab on the top ribbon and click Text to Columns. In the wizard that appears, leave the default General selection and click Finish immediately. Excel will re-evaluate the entire column and convert anything that looks like a number into an actual numerical value.
  4. Method 3: Using the VALUE Function: If you want to keep your original data intact and create a new sorted column, insert a blank column next to your order numbers. In the first cell of the new column, type =VALUE(A2) (replacing A2 with the cell reference of your first order number). Press Enter and drag the fill handle down to apply the formula to all rows. This converts the text string into a number.
  5. Apply Numerical Sorting: Now that the data is formatted as numbers, select any cell within your dataset. Go to the Data tab and click the Sort A to Z (Smallest to Largest) or Z to A (Largest to Smallest) button. You will notice that Excel now asks if you want to "Expand the selection" if you only selected one column; always choose Yes to ensure the rest of the order details stay aligned with the correct order number.
  6. Verify the Result: Scroll through your list. The sequence should now follow a logical mathematical progression (e.g., 1, 2, 3... 9, 10, 11) rather than a character-based progression (1, 10, 11... 2, 20).

Common Mistakes

One of the most frequent errors is changing the cell format using the Home tab dropdown after the numbers have already been entered. Simply changing the format from Text to Number in the ribbon often does nothing to the existing data; it only tells Excel how to treat future data entered into those cells. To trigger the change for existing data, you must use one of the active conversion methods like Text to Columns or double-clicking into the cell to "refresh" it.

Another common mistake is ignoring the "Expand the Selection" prompt. If you select only the order number column and click sort, Excel will move the order numbers but leave the customer names, dates, and totals in their original positions. This effectively scrambles your database, assigning the wrong order numbers to the wrong customers. Always ensure the entire table is selected or that you agree to expand the selection.

Users also frequently try to use the VALUE function but forget to "Paste as Values" before deleting the original text column. If you delete the original column that the VALUE formula was referencing, you will get a #REF! error across your entire sheet. Always copy the formula results and use Paste Special > Values to lock the numbers in place.

Tips

To prevent this issue from happening in the future, format your columns as Number or General before you import or type your data. If you are importing a CSV file, use the "Get Data" or "Import from Text/CSV" tool in the Data tab. This allows you to define the data type for each column during the import process, ensuring order numbers are recognized as integers from the start.

If your order numbers contain leading zeros (e.g., 000123) and you need to keep them, be careful. Converting these to numbers will remove the leading zeros because mathematically, 000123 is the same as 123. If you must keep the zeros but want them to sort numerically, you should create a "helper column" using the VALUE function for sorting purposes, while keeping the original text column for display and printing.

For extremely large spreadsheets, using the Text to Columns method is significantly more performant than using a helper column with formulas. Formulas increase the file size and can slow down calculation speeds, whereas Text to Columns performs a one-time hard conversion of the data.

Troubleshooting

If you have followed the steps and the numbers still sort as 1, 10, 2, you likely have hidden characters or non-breaking spaces in your cells. This often happens with data exported from web-based accounting software. To fix this, use the Find and Replace tool (Ctrl + H). In the "Find what" box, hold the Alt key and type 0160 on your number pad (this is the code for a non-breaking space), and leave the "Replace with" box empty. Click Replace All. Once these invisible characters are gone, the Convert to Number tool will work.

If the numbers are converted but appear as scientific notation (e.g., 1.23E+10), your column is too narrow or the number is too long for the default General format. To fix this, right-click the column header, select Format Cells, choose Number, and set the Decimal places to 0. This will force Excel to show the full order number.

If you see a #VALUE! error after using the VALUE function, it means there is a non-numeric character (like a letter or a symbol) inside the cell. Check for prefixes like "ORD-123". If your order numbers have prefixes, you cannot convert them to numbers directly. You must first remove the prefix using the formula =SUBSTITUTE(A2, "ORD-", "") and then wrap that in a VALUE function: =VALUE(SUBSTITUTE(A2, "ORD-", "")).

Frequently Asked Questions

Why does Excel sort 1, 10, 2 instead of 1, 2, 10?

This happens because the cells are formatted as Text. In text sorting, Excel looks at the first character; since "1" comes before "2", any number starting with 1 (like 10, 100, or 1000) is placed before the number 2.

Will converting to numbers delete my data?

No, converting the format does not delete the data, but it may remove leading zeros. For example, 005 becomes 5. If those zeros are critical for your records, use a helper column for sorting.

Can I sort numerically if my order numbers have letters in them?

No, any cell containing a letter is automatically treated as text. To sort these numerically, you must use a formula to strip away the letters into a separate column and sort by that new numerical column.

Does the "Convert to Number" warning appear for every cell?

The warning appears as a small green triangle in the corner of the cell. If you don't see it, you can enable it in File > Options > Formulas > Error Checking, or simply use the Text to Columns method which works regardless of the warning icon.

How do I stop Excel from automatically converting long order numbers to scientific notation?

Format the column as "Number" with 0 decimal places before entering the data, or format the cells as "Text" if you do not need to perform mathematical calculations on the order numbers.