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:

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 

snapfade

New Member
Joined
Dec 6, 2011
Messages
20
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
 

snapfade

New Member
Joined
Dec 6, 2011
Messages
20
Hmmm. But under your suggestion, all cells are unlocked to facilitate sorting while the worksheet is protected. What am I missing?
 

snapfade

New Member
Joined
Dec 6, 2011
Messages
20
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
 

Watch MrExcel Video

Forum statistics

Threads
1,099,078
Messages
5,466,488
Members
406,484
Latest member
kaksolver

This Week's Hot Topics

Top