Jump to content
groovyPost Forums

How do you allow a table to be sorted in a protected Excel sheet


Recommended Posts

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

Abby

Link to post
Share on other sites

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.

Important

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.

Link to post
Share on other sites

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.

Important

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.

 

thanks Simon

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By micalhassey
      I want to best solution for recovering Excel sheet password because I don’t remember my Excel file password please any one suggest me to remove my Excel file password….Thanks
    • By shockersh
      Quick question for you groovy excel ppl out there. I'm working with a vendor and need to calculate the discount and/or increase. I know there is a simple excel formula I can use. Just looking for a tip for it.
      Thanks!
    • By Steve
      Question from Reader - Email Form
       
       
      Hi Tom,
       
      Ouch. I know how it feels losing a days worth of work. The worst part is when you have to recreate what you've already done.
       
      To answer your question, when you found the Entry "OutlookSecureTempFolder" what was the path in the DATA column? I assume you reviewed this post here to find it. It looks like you found the registry key entry so your more than 1/2 way there. Find that key again and you should have the path to your OLK folder and your Excel should be sitting there.
       
      Now the path might be a bit confusing because with Outlook 2007, there actually is "NOT" an OLK folder. For instance, on my XP/Outlook 2007 install, my OLK folder or "Temp Outlook Folder" / "OutlookSecureTempFolder" is:
       
      "c:\Documents and Settings\mrgroove\Local Settings\Temporary Internet Files\Content.Outlook\4V32TZLP"
       
      So if you look on your box you will find what your looking for in the "Content.Outlook" folder. Take a look there and your golden.
       
      Let me know how this works for you!
    • By Twitz
      How do you save a shortcut in your favorites bar to another users inbox when they have given you delagate rights to their mailbox.
    • By Austin
      Beatrice writes:

      I have a question, I know how to do a data validation drop down but I need the one list with two buttons in the same cell and a range of years.Do you know how to do this?
      I work for the school district and they need a particular calendar. They have a cell where you can list the year but it list whole number with a range of 1999 to 2999 and has two buttons.... one to go up in years and one to go lower... Hope this makes sense
  • Who's Online   0 Members, 0 Anonymous, 21 Guests (See full list)

    There are no registered users currently online

×
×
  • Create New...