login about faq

I have a protected worksheet but I want users to be able to sort one of the tables.

When protecting the sheet I checked the options allowing users to select cells, sort and use auto filter but it won’t allow the table to be sorted without entering the password for the sheet. What am I doing wrong?

Excel 2010


asked Aug 03 '12 at 06:40

Abby's gravatar image


Hi Abby,

You aren’t doing anything wrong. Those checkboxes have never allowed protected cells to be sorted. All they do is make the sort option available on a protected sheet to be used on cells that are unprotected.

You will need to create a macro which unprotects the sheet, sorts your table then re-protects it.

The code to unprotect and protect would be

Sheets("Sheet1").Unprotect Password:="mypassword"

Sheets("Sheet1").Protect Password:="mypassword"

Where sheet1 is the name of the sheet you are working on and mypassword is the password you used to protect the sheet.

You just need to add the code to do whatever type of sort you want. If you don’t know how to write the macro to do the sort, you could record one and add the code to unprotect / re-protect.


In order to stop people looking at the macro and seeing the password you will need to lock it for viewing, to do this:

  1. Open the Visual Basic editor
  2. Right click on the VBAProject
  3. Choose “VBAProject Properties”
  4. Select the “Protection” tab
  5. Check the “Lock project for viewing” box
  6. Enter your password
  7. Click “OK”

alt text

To enable the password you will need to Close the VBA editor and save the workbook.

When you re-open the workbook and click the Macros icon all the options for the macro are greyed out apart from Run

alt text

You can still open the Visual Basic editor but when you click on the project it asks for a password.

alt text

You will need to do a different macro for each type of sort on each column of the table that users will need to perform.

You could also add macro buttons to the sheet and label then with the sort that they will activate.


answered Aug 04 '12 at 11:37

Simon%20H's gravatar image

Simon H

thanks Simon

(Aug 06 '12 at 18:50) Abby Abby's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:
    [text](http://url.com/ "title")
  • image:
    ![alt text](/path/img.jpg "title")
  • numbered list:
    1. Foo
    2. Bar
  • Code:
    • Within a paragraph:
      surround code with grave accents (backticks)
    • Code snippet:
      Select the text and use the button on the icon of zeros and ones
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Aug 03 '12 at 06:40

Seen: 5,417 times

Last updated: Aug 06 '12 at 18:50

groovyAnswers © 2007 - 2011 All Rights Reserved | Privacy | Contact