Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sorting columns in a protected worksheet

Posted on 2013-12-26
2
Medium Priority
?
314 Views
Last Modified: 2013-12-26
I have a worksheet where all cells are protected, however, I would like to allow users to sort.  I have selected the options for allowing 'sorting' and 'auto filer' when setting the password, however, I believe I must also have some kind of code in there as well.

I found the below code somewhere else which I am not sure will work, because I currently have code in there to allow users to group/ungroup on another sheet in the workbook.  If the below code is correct, how would I incorporate this into my existing code as shown on the sample attached?  If the code is incorrect, what would be the correct code and how should it be incorporating into the existing code?  Thanks!

Private Sub Workbook_Open()
For Each ws In ActiveWorkbook.Worksheets


ws.Protect Password:="", AllowSorting:=True

Next
End Sub
sample.xlsm
0
Comment
Question by:daisypetals313
2 Comments
 
LVL 23

Accepted Solution

by:
Michael Fowler earned 2000 total points
ID: 39740967
The problem is bit more complicated than the answer you proposed.

Here is a really good article which includes 2 different solutions to the issue

http://blog.softartisans.com/2013/10/01/kb-sorting-locked-cells-in-protected-worksheets/

Michael
0
 

Author Closing Comment

by:daisypetals313
ID: 39740980
It worked!  I used the Scenario 1 option from the article.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question