How to Get Rid of Sort in Excel and Restore Data Order
In this article
To get rid of a sort in Excel, the fastest method is to use the Undo command (Ctrl + Z) immediately after the sort is applied. However, because Excel does not have a built-in "Unsort" button that remembers the previous sequence of rows once the file is saved or closed, the only permanent way to restore the original order is by using a dedicated Index or ID column created before the sorting took place. If you have an ID column, you simply sort that column from Smallest to Largest to return the data to its original state.
What You'll Need
- A computer with Microsoft Excel installed (Windows or macOS).
- The spreadsheet containing the sorted data.
- An existing Index/ID column (if you are attempting to restore order after saving and closing the file).
Step-by-Step
Depending on when you realized the sort was a mistake, use one of the following three methods to revert your data. Please note that menu labels may differ slightly depending on your version of Excel, your operating system, or your regional settings.
Method 1: Using the Undo Command (Immediate Fix)
- Click anywhere inside your worksheet to ensure the window is active.
- Press Ctrl + Z on your keyboard (Command + Z on a Mac).
- Alternatively, click the curved Undo arrow located in the Quick Access Toolbar at the very top left of the Excel window.
- Continue pressing Undo if you performed other actions after the sort that also need to be reversed.
Method 2: Using an Index Column (Permanent Fix)
This method only works if you created a column of sequential numbers (1, 2, 3, etc.) before you sorted your data. If you have this column, follow these steps:
- Locate the Index or ID column in your dataset.
- Click on any cell within that specific column to select it.
- Navigate to the Data tab on the top Ribbon.
- In the Sort & Filter group, click the Sort A to Z button (Smallest to Largest).
- Excel will automatically rearrange all rows based on the numerical order of the index, effectively "unsorting" the other columns and returning the data to its original entry sequence.
Method 3: Reverting to a Previous Version (Cloud Files)
If your file is saved on OneDrive or SharePoint, you can roll back the entire document to a version from before the sort occurred.
- Click the File menu in the top left corner.
- Select Info from the side menu.
- Click on Version History.
- A panel will appear on the right showing various timestamps of when the file was saved.
- Browse through the versions and click Open version for a timestamp that precedes the sorting action.
- Once the old version opens in a new window, verify the data order is correct.
- Click Restore in the yellow bar at the top of the screen to replace the current sorted version with the original one.
Common Mistakes
One of the most frequent errors users make is sorting only a single column instead of the entire dataset. This happens when a user selects one column and clicks "Sort" without expanding the selection. This results in "scrambled data," where the sorted column no longer aligns with the information in the adjacent columns. Once this happens, the relationship between the data points is broken, and simply "unsorting" will not fix the misalignment.
Another common mistake is saving the workbook after performing a sort. Many users assume that the Undo history is preserved across sessions. In reality, once you save and close an Excel file, the Undo stack is cleared. If you did not have an Index column, you cannot use Ctrl + Z to revert the sort after reopening the file.
Users also frequently forget to include headers in their sort range. If the "My data has headers" checkbox is unchecked during a custom sort, Excel will treat your column titles as data and sort them into the middle of the list, which can be confusing when trying to restore the original order.
Tips
To prevent future sorting headaches, always create a "Row ID" column before performing any data manipulation. To do this quickly, type "1" in the first cell and "2" in the second, select both, and drag the fill handle (the small green square at the bottom right of the selection) down to the end of your dataset. This creates a permanent numerical anchor for your data.
Consider converting your data range into an official Excel Table by pressing Ctrl + T. Tables make sorting and filtering much safer because they treat the entire row as a single record, significantly reducing the risk of accidentally sorting only one column and scrambling your data.
If you are working with a critical dataset, create a duplicate tab of your raw data before you begin sorting or filtering. Right-click the sheet tab at the bottom, select Move or Copy, check Create a copy, and click OK. This provides a "safe zone" that you can refer back to if the sorting process goes wrong.
Troubleshooting
If you attempted to sort by an Index column but the data did not return to the original order, check for duplicate numbers in your Index column. If two rows have the same ID number, Excel will sort them randomly relative to each other, meaning the order might not be exactly as it was originally.
If the Undo button is greyed out, it is likely because the file was saved, closed, or you are working in a "Read-Only" or "Protected View" mode. In these cases, check if the file is stored on OneDrive to use the Version History method described above.
If you find that your data is "scrambled" (meaning the rows no longer match), and you have no backup or Index column, the data cannot be automatically restored. You will have to manually move the rows back into place or re-import the data from the original source file.
Frequently Asked Questions
Is there a specific "Unsort" button in Excel?
No, Excel does not have a dedicated "Unsort" button. Sorting is a destructive action that changes the physical order of the rows. To reverse it, you must use Undo or sort by a previously created ID column.
Will sorting my data delete any information?
Sorting does not delete data, but it changes the sequence. However, if you sort only one column without expanding the selection to the rest of the table, you will lose the logical connection between your data points, which effectively ruins the integrity of the record.
How do I stop Excel from sorting my headers?
When using the Sort dialog box (Data > Sort), ensure that the checkbox labeled "My data has headers" is checked. This tells Excel to ignore the first row when rearranging the data.
Can I use a formula to unsort my data?
There is no formula that can "undo" a sort once the cells have been physically moved. Formulas like SORT or FILTER create a new sorted view of the data elsewhere, but they do not change the original source. If the original source was sorted manually, a formula cannot know what the previous order was.
Does the Undo command work after I save the file?
No, saving the file does not clear the undo history in the current session, but closing the file and reopening it does. Once the application is closed, the undo history is wiped.
What is the best way to keep track of original order?
The gold standard is adding a sequential ID column (1, 2, 3...) as the very first step of your data entry process. This ensures that no matter how many times you sort or filter, you can always return to the original entry sequence.