Written by Allen Wyatt (last updated October 16, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
Nigel randomly entered a few hundred expense slips into a worksheet using the worksheet line number as the reference number for the slip. When he sorted the data by date, the line number is no longer the correct reference number for the slip. (He now knows this was a blunder.) Nigel wonders if it is possible to remove all sorting in a worksheet and return the data to simply the order in which the data records were entered.
The answer to this question is "it depends." What it depends on is when you want to actually remove all the sorting.
For instance, if you sort the data in a worksheet and then don't do anything else, you can press Ctrl+Z to undo the effects of the sort. If, however, you do a bunch of other tasks, then the availability of that Ctrl+Z becomes more and more remote. It becomes completely unavailable if you run a macro (which wipes out the undo stack) or if you exit Excel.
If you want to undo the sorting effects and you have yet to save the Excel workbook on which you are working, you could always close it without saving. When you again open the workbook, the data will still be in the original order, but you will have lost anything you previously did after the sorting and before you closed the workbook.
Finally, if your workbook is saved on either a cloud service (such as OneDrive) or on a company server, it may be possible that you can go back and retrieve a backup version of your workbook. Check out the settings in your cloud service or check with your network administrator to see what is possible in this regard.
The best way to always allow resorting of your data is to make sure you include an "index column." This column would be nothing other than an incremental count of rows: 1, 2, 3, 4, etc. As long as those values aren't based on formulas, you can—at any point—resort your data based on the contents of the column. Your data will then be sorted in its original order.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11314) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
When you sort data that contains both numbers and text, you may not get exactly the result that you expected. To know ...
Discover MoreSorting information in Excel is a common task. Sorting information that isn't in the primary order that you need can be a ...
Discover MoreWhen formatting the layout of your worksheet, Excel allows you to easily merge adjacent cells together. This can cause ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-10-16 22:55:12
Don White
Hi Allen,
Here in Australia, we are heading into Summer, so snow is far from our minds. We are however heading into bushfire season, so we hope it’s not like 2019-20.
When sorting, I have had a few disasters over the years working with big spreadsheets with university student data. So, I now save my spreadsheets with a date and time before doing a big sort and then continue to save regularly with file name updated. If there are no problems, I can then go back and deleted the progressive files.
Another trap I have fallen into is to find I have only sorted a portion of the data. This can occur due to inserting a new column into the data. If this column has no data entries then it splits the spreadsheet into two separate data ranges… and only works on one of them. To guard against this problem, I have learnt to put in an identifier as the columns at each edge of the spreadsheet. This can be a numeric reference number, but for students, I use their ID number. I then just have to remember to check that these two columns are in sync with each other, which is easy to do using the compare function.
2021-10-16 08:56:01
Roy
In a "by the way" sort of way, one could point out that ANY time one might want to restore a particular order, even though the interim work may delete rows and change values that would not let the original sort parameters place all items in their original order, the helper column with index numbers in it before one sorts for the different purpose/s will, in the end, let you restore to original order for the records.
And if one was adding rows, one could leave that index value untouched as a true null to Excel until after resorting whereupon all the new rows would sort to the absolute bottom. They could then be assigned index numbers of their own, either starting with the next highest, or with the next highest relative to the original highest, if that row got deleted. (The latter would require you to have noted down that original highest number early on, for this purpose, or to be able to learn it any of various ways.)
All in all, the sequential numbering indexing is useful in many ways, though surely, the Tip's, and the above, would be the most commonly occurring.
Caveat: Do NOT rely upon any formula though. Type a 1 in the first cell and insert a sequence, or do a formula, but then Copy it and Paste|Special|Values to lose the formulas. Or you will be in the same boat as Nigel. Slightly different reason/path, but the same boat.
2021-10-16 06:31:56
Alan Bowen
Hi Allen
Here in Cornwall UK the temperature is in the mid teens Celsius so snow is a long way off, I hope. On the sorting issue, I've been caught out by that when I 've used Excel professionally. My solution was to insert a column of sequential numbers at column A starting with 1 at the first line of data. Then if the sort goes wrong you can resort using only that column to get back to where you were originally. Alternatively make a copy of the the worksheet before you sort and delete it as necessary.
Cheers Alan Bowen
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments