Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Sorting Data on Protected Worksheets.
Written by Allen Wyatt (last updated April 2, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003
When you protect a worksheet, Excel stops users from performing a wide variety of tasks on the data in the worksheet. One of the things that the user can no longer do is to sort data. What if you want the user to be able to sort data, but still have the sheet protected?
If you are using Excel 2002 or Excel 2003 the answer is quite easy: These versions of Excel allow you to specify what users can and cannot do with a protected worksheet. When you choose Tools | Protection | Protect Sheet, Excel displays the Protect Sheet dialog box. At the bottom of the dialog box is a long list of check boxes. All you need to do is select what the user should be able to do with the worksheet. One of the options (you need to scroll down a bit) is Sort. If you select this option, then users can sort protected data.
If you are using an older version of Excel, the solution is to create a macro that unprotects the worksheet, sorts the data, and then protects the worksheet again. The following is a simple example:
Sub Sorting() ActiveSheet.Unprotect Range("A1:D100").Sort Key1:=Range("A1"), _ Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, _ Orientation:=xlTopToBottom ActiveSheet.Protect End Sub
This example sorts the data in the range A1:D100 based on the contents of column A. The macro illustrates the general concept behind this approach, but you will need to modify it to reflect the needs of your data and your users.
If you go the macro route, you need to assign the macro to either a toolbar button or a menu command. If you don't the user will never be able to use it, since the Macros menus are disabled in a protected document.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2458) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Sorting Data on Protected Worksheets.
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!
When formatting the layout of your worksheet, Excel allows you to easily merge adjacent cells together. This can cause ...
Discover MoreExcel allows you to sort but up to three columns, but you may want to sort by more than that. This tip provides ways you ...
Discover MoreSorting by dates is easy, and you end up with a list that is in chronological order. However, things become a bit more ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
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