VBA to Sort Protected and Locked worksheet

snapfade

New Member
Joined
Dec 6, 2011
Messages
20
I need a VBA macro that will

  1. unprotect the worksheet with password
  2. prompt the user for one field to sort ascending or descending
  3. sort the worksheet
  4. protect the worksheet with password
  5. exit
The worksheet has many calculation fields that are locked and not selectable but a locked field may be chosen for sorting.

I have seen bits and pieces of this request but cannot seem to put it all together. I'm also a VBA novice so please go easy on me! :)

Thanks in advance for any help you may provide.

tom
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
If you unlock the cells before protecting the worksheet and check Sort in the 'Allow users' list when you protect it, you won't need any VBA code.
 
Upvote 0
So noted. It seems simple enough but I have traveled down this path for reasons I can't, at the moment, fully recall. My client wants the cells locked and that made sense to me at the time. Your suggestion makes sense. Can I disallow viewing cells that would be unlocked using your idea? tom
 
Upvote 0
Hmmm. But under your suggestion, all cells are unlocked to facilitate sorting while the worksheet is protected. What am I missing?
 
Upvote 0
Are we back to square one? The cells I want to sort include cells that were locked and not selectable by user. The client, I recall, does not want his people viewing the formulas but wants them to be able to sort the worksheet that includes these locked cells. tom
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,762
Members
449,048
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top