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.
With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company.
Learn more about Allen...
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.
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.
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.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!