PDA

View Full Version : custom views with a protected worksheet



cellist
05-09-2014, 03:47 PM
I'd like to use VBA to invoke a Custom View ("CV"), so that the user doesn't need to first unprotect the worksheet and then remember to protect it again after the CV has been invoked. The user would initiate the VBA code by clicking a command button on the worksheet. The code would work something like this:


Collect the names of the CVs already defined for the worksheet.
Display a drop-down list of the names; user chooses the desired CV.
Collect the current protection settings (what's allowed when the worksheet is protected).
Unprotect the worksheet.
Invoke the desired CV using the choice from step.
Protect the worksheet using the protection settings saved in step 3



Thanks in advance for your consideration,
Phil

Aussiebear
05-09-2014, 04:53 PM
Can you upload a sample workbook please Phil? This will give those members interested in assisting you something to work with, and go a long way to fulfilling your request. To upload an attachment, click on Go Advanced, and scroll down to Manage Attachments.

cellist
05-10-2014, 01:01 PM
Attached is an example that has two custom views. The worksheet is, initially, protected so you cannot switch views without unprotecting the sheet.

cellist
05-11-2014, 06:48 AM
OOPS. The example I posted is NOT PROTECTED, so it does not need to be UNPROTECTED to display custom views. Try this one to demonstrate the behavior I want to deal with:

xld
05-12-2014, 04:40 AM
Public Sub ShowViews()
ActiveSheet.Unprotect
Application.Dialogs(xlDialogCustomViews).Show
ActiveSheet.Protect
End Sub