Hi Jim,
Great! Here are the details...
Insert a UserForm, I renamed mine "Administrative Rights". The following is what mine looks like, but you can obviously create yours differently if you would like.
Here are the "AdministrativeRights" UserForm Properties:
Here are the "OKButton" Properties
Here are the "PasswordBox" Properties
Here is the Code
In the UserForm
VBA Code:
Private Sub OKButton_Click()
Dim wSheet As Worksheet
Application.ScreenUpdating = False
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=PasswordBox.Text
Else
wSheet.Protect Password:=PasswordBox.Text, DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowFormattingRows:=True, UserInterfaceOnly:=True, AllowFiltering:=True
End If
Next wSheet
Application.ScreenUpdating = True
Unload Me
End Sub
In a VBA Module
VBA Code:
Sub ShowPass()
AdministrativeRights.Show
End Sub
I usually just insert a shape, label it "Administrative Rights" and assign the "ShowPass()" Macro to it.
This is the part of my UserForm Code where I define the "User Profile/Rights".
VBA Code:
wSheet.Protect Password:=PasswordBox.Text, DrawingObjects:=False, Contents:=True, Scenarios:= True, AllowFormattingRows:=True, UserInterfaceOnly:=True, AllowFiltering:=True
Here are the options (If left out of your code, the "Default" applies):
- "DrawingObjects:=True" (Default) - To Protect Drawing Objects (i.e Shapes);
- "Contents:=True" - Protects Locked Cells
- "Scenarios:=True" (Default) - Protects Scenarios
- "AllowFormattingCells:=False" (Default) - If "True", allows Users to Format any Cell
- "AllowFormattingColumns:=False" (Default) - If "True", allows Users to Format any Columns
- "AllowFormattingRows:=False" (Default) - If "True", allows Users to Format any Rows
- "AllowInsertingColumns=False" (Default) - If "True", allows Users to Insert Columns
- "AllowInsertingRows=False" (Default) - If "True", allows Users to Insert Rows
- "AllowInsertingHyperLinks=False" (Default) - If "True", allows Users to Insert HyperLinks
- "AllowDeletingColumns=False" (Default) - If "True", allows Users to Delete Columns
- "AllowDeletingRows=False" (Default) - If "True", allows Users to Delete Rows
- "AllowSorting=False" (Default) - If "True", allows Users to Sort Data
- "AllowFiltering=False" (Default) - If "True", allows Users to Filter Data
- "AllowUsingPivotTables=False" (Default) - If "True", allows Users to Use Pivot Tables
- "UserInterfaceOnly:=False" (Default) - If "True", allows Users cannot edit the User Interface, but can Edit VBA Macros. If "False", both are protected
I think that's all of it...
I'm confident that if you go through this process twice, once for "Senior Management" and once for "Managers", and differentiate privileges between the two user group using the ProtectContents options listed above, that you will be ale to create two "Password-enabled" User Profiles. Use one to lock the file before sending to Senior Management and the other to lock the file before sending to Managers.
Hope this works out for you and please let me know how it goes or if you have any issues.