Hi Experts
can anyone combine these 2 VBA macro's into 1 macro
one macro will protect all worksheet with an inputbox
second macro will unprotect all worksheet with just given password
can anyone combine these 2 VBA macro's into 1 macro
one macro will protect all worksheet with an inputbox
second macro will unprotect all worksheet with just given password
VBA Code:
Sub protect_all_sheets()
top:
pass = InputBox("password?")
repass = InputBox("Verify Password")
If Not (pass = repass) Then
MsgBox "you made a boo boo"
GoTo top
End If
For i = 1 To Worksheets.Count
If Worksheets(i).ProtectContents = True Then GoTo oops
Next
For Each s In ActiveWorkbook.Worksheets
s.Protect Password:=pass, DrawingObjects:=False, Contents:=True, Scenarios:=True
Next
Exit Sub
oops: MsgBox "I think you have some sheets that are already protected. Please unprotect all sheets then running this Macro."
End Sub
Sub unprotect_all_ws()
Dim ws As Worksheet
For Each ws In Worksheets
ws.UnProtect "123"
Next ws
End Sub