All worksheets should be protected from the prying fingers of end users, but this causes a problem when you want to programatically make changes.
What I do is I have two subroutines Lock_Sheet and Unlock_Sheet:
The actual statement that does the work is
and
However, there are a lot of other things to consider as well such as:
- Process events
- Process Calculations
- Display changes as they happen or not
- Display alerts that might be triggered or not
That's why there is a hell of a lot more code surrounding the relevant statements above.
I tend to use a push down stack to store everything that I need to keep track of such as the current state of the worksheet, messages being displayed to the user etc. In that way I can call these routines as many times as I like as long as the calls happen in pairs.
An example of how to do this is below:
Regards
Rich
Bookmarks