C
Colin Hayes
Hi
All I'm hoping someone can help with placing a Yes / No popup in an
existing macro.
I use this macro to protect / unprotect my worksheets.
Sub Protect_Unprotect()
Const PWORD As String = "password"
Dim wkSht As Worksheet
Dim statStr As String
Application.ScreenUpdating = False
For Each wkSht In ActiveWorkbook.Worksheets
With wkSht
statStr = statStr & vbNewLine & "Sheet " & .Name
If .ProtectContents Then
wkSht.Unprotect Password:=PWORD
statStr = statStr & ": Unprotected"
Else
wkSht.Protect Password:=PWORD, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowFiltering:=True ', _
AllowFormattingCells:=True, _
AllowDeletingRows:=True, _
AllowInsertingColumns:=True, _
AllowInsertingHyperlinks:=True, _
AllowInsertingRows:=True, _
Userinterfaceonly:=True, _
AllowDeletingColumns:=True, _
AllowUsingPivotTables:=True
statStr = statStr & ": Protected"
End If
End With
Next wkSht
Application.ScreenUpdating = True
MsgBox Mid(statStr, 2)
End Sub
My problem is that for some workbooks i need all of the qualifying
permissions listed here to be reinstated on protection. In others , I
don't need them. In these the limited basic permission to select locked
/ unlocked in needed.
What I'm trying to put in place is a Yes / No popup asking 'All
qualifying permissions?'. If the answer is 'Yes' then it proceeds
through the macro. If the answer is 'No' then it jumps over the
permissions listed in the macro and protects with the basic select
locked / unlocked cells.
Can someone help with this? I did try some coding of my own , but am
struggling to find the right place in the code to place the popup VBA.
Grateful for any help.
All I'm hoping someone can help with placing a Yes / No popup in an
existing macro.
I use this macro to protect / unprotect my worksheets.
Sub Protect_Unprotect()
Const PWORD As String = "password"
Dim wkSht As Worksheet
Dim statStr As String
Application.ScreenUpdating = False
For Each wkSht In ActiveWorkbook.Worksheets
With wkSht
statStr = statStr & vbNewLine & "Sheet " & .Name
If .ProtectContents Then
wkSht.Unprotect Password:=PWORD
statStr = statStr & ": Unprotected"
Else
wkSht.Protect Password:=PWORD, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowFiltering:=True ', _
AllowFormattingCells:=True, _
AllowDeletingRows:=True, _
AllowInsertingColumns:=True, _
AllowInsertingHyperlinks:=True, _
AllowInsertingRows:=True, _
Userinterfaceonly:=True, _
AllowDeletingColumns:=True, _
AllowUsingPivotTables:=True
statStr = statStr & ": Protected"
End If
End With
Next wkSht
Application.ScreenUpdating = True
MsgBox Mid(statStr, 2)
End Sub
My problem is that for some workbooks i need all of the qualifying
permissions listed here to be reinstated on protection. In others , I
don't need them. In these the limited basic permission to select locked
/ unlocked in needed.
What I'm trying to put in place is a Yes / No popup asking 'All
qualifying permissions?'. If the answer is 'Yes' then it proceeds
through the macro. If the answer is 'No' then it jumps over the
permissions listed in the macro and protects with the basic select
locked / unlocked cells.
Can someone help with this? I did try some coding of my own , but am
struggling to find the right place in the code to place the popup VBA.
Grateful for any help.