Home life · Updated
Sort Numbers in Excel Numerically: Step-by-Step
Quick answer Sorting numbers in Excel puts them in ascending (smallest to largest) or descending (largest to smallest) order. This guide covers the basic sort, fixing text-formatted numbers, and sorting by multiple columns.
What You’ll Need
- A computer with Microsoft Excel (2013 or later, including Microsoft 365).
- Your spreadsheet open with the numbers you want to sort.
- If your data has headers (like “Sales” or “Amount”), know which row contains them.
Step-by-Step
- Select the data range – Click and drag to highlight all the cells containing numbers you want to sort. Include the header row if you have one, but do not include any empty rows or columns. For a single column, just select that column’s data (e.g., A2:A100).
- Open the Sort dialog – Go to the Data tab on the ribbon. In the Sort & Filter group, click Sort. This opens a dialog box. (Alternatively, you can use the A→Z or Z→A buttons for a quick sort, but the dialog gives more control.)
- Set the sort key – In the dialog, under Column, choose the column that contains your numbers. If your selection had a header row, check the box “My data has headers” at the top right. Under Sort On, keep “Cell Values”. Under Order, choose “Smallest to Largest” for ascending or “Largest to Smallest” for descending.
- Add more levels (optional) – If you want to sort by another column after the first (e.g., sort by region, then by sales amount), click Add Level and repeat step 3 for the second column. This is useful when you have multiple rows with the same value in the first column.
- Apply the sort – Click OK. Excel rearranges your rows according to the numeric order. If you selected only one column without expanding the selection, Excel will ask if you want to sort the entire selection or just that column. Choose “Expand the selection” to keep rows intact.
Common Mistakes
- Selecting only one column – If you highlight just a single column and sort, Excel will sort that column independently, breaking the association with other data in the same rows. Always select the entire range of related data.
- Numbers stored as text – If your numbers are left-aligned in the cell (default text alignment) or have green triangles in the corner, they are text, not numbers. Sorting text puts “10” before “2” because it compares character by character.
- Forgetting headers – If you don’t tell Excel that your first row is a header, it will sort that row along with the data, moving your column titles into the middle of the data.
- Hidden rows or filters – If you have a filter applied or rows hidden, sorting only affects visible cells, which can produce unexpected results. Clear filters first.
Tips
- Use the quick sort buttons – For a simple one-column sort, click the A→Z (ascending) or Z→A (descending) icon on the Data tab or Home tab. It’s faster than the dialog.
- Convert text to numbers – If you see green triangles, select the column, click the warning icon, and choose “Convert to Number”. Or use the VALUE function in a new column:
=VALUE(A2)and copy down. - Sort by multiple columns – Use the Sort dialog to add levels. This is essential for data like a list of names and ages where you want ages sorted within each name group.
- Create a backup – Before sorting a large dataset, copy the sheet (right-click the tab, choose “Move or Copy”, check “Create a copy”). If something goes wrong, you have the original.
- Use a table – If you convert your data to a Table (Ctrl+T), sorting becomes more intuitive, and filters are added automatically. Tables also keep formatting consistent.
Troubleshooting
- Sorting gives wrong order (10 before 2) – This means your numbers are text. Select the column, go to Data > Text to Columns, click Finish. This often converts text to numbers. Alternatively, use the VALUE function as described above.
- Data becomes misaligned – You sorted only one column. Undo (Ctrl+Z), then reselect the entire range (all columns) before sorting again. If you have a table, sorting any column automatically sorts the whole table.
- Header row gets sorted – In the Sort dialog, make sure “My data has headers” is checked. If you used the quick buttons, you might have selected the header row as part of the data. Undo and reselect without the header, or use the dialog.
- Sort button is grayed out – This happens when your worksheet is protected. Go to Review > Unprotect Sheet (you may need the password). Also, if you have merged cells, sorting can be disabled; unmerge them first.
- Sort not working with filtered data – Clear the filter (Data > Clear) before sorting. Sorting with filters only sorts the visible rows, which can corrupt your data.
Frequently Asked Questions
Why does Excel sort numbers as text?
Numbers can be stored as text if they were imported from a CSV, copied from another program, or have leading zeros or apostrophes. Excel treats them as text strings, so sorting is alphabetical. Convert them using Text to Columns or the VALUE function.
How do I sort numbers in a row (horizontally)?
Select the row, then go to Data > Sort. In the dialog, click Options and choose “Sort left to right”. Then pick the row you want to sort by and the order.
Can I sort by a custom order, like high, medium, low?
Yes. In the Sort dialog, under Order, choose “Custom List”. You can create a list like High, Medium, Low and then sort by that. This works for text, not numbers.
What if I have blank cells in my numeric column?
Blank cells are placed at the end when sorting ascending, and at the beginning when sorting descending. If you want blanks to be treated as zeros, you’ll need to fill them with 0 first.
Does sorting affect formulas?
Sorting moves entire rows, so formulas that reference cells in that row will still refer to the same cell addresses, but the values may change if the formula references a cell that moves. It’s safer to use absolute references or tables if you rely on formulas.
How do I sort by multiple columns without mixing up rows?
Use the Sort dialog and click “Add Level”. Set the first column as the primary sort, then the second, etc. Excel will sort by the first, then within ties, by the second. Make sure you select the entire data range first.
Related
- How to Put iPhone on DND (Do Not Disturb)
- How to Organize Google Sheets by Date
- How to Organize Google Calendar: A Step-by-Step Guide
Sources: Microsoft Support. Menus and buttons can differ slightly by version. Spotted something out of date? Tell us.