A
Adam
I have a VBA code in Module1 of a workbook which protects all the sheets with
the same password. The code is
Sub LockEm()
Dim i As Long
Dim PW As String
Dim WS As Worksheet
PW = InputBox("Enter password to protect all sheets:")
On Error GoTo MyErr
For Each WS In ActiveWorkbook.Worksheets
WS.Protect (PW)
Next
MsgBox i & " errors while protecting", vbInformation
Exit Sub
MyErr:
i = i + 1
Resume Next
End Sub
Now, I have a macro in the same module in which I would like to unprotect
the sheet with the password entered when protecting all the sheet, execute
some activities and then reprotect it with the same password, i.e. lets say I
i have the macro
Sub xxx()
Range("C4").Select
ActiveCell.FormulaR1C1 = "cc"
End Sub
Where and how do I enter the code?
I assume I need to make PW public or something (I'm quite new at VBA)
Secondly, I would like to apply the same thing as above to a worksheet event
that I have in a specific sheet
Any ideas?
Thanks
the same password. The code is
Sub LockEm()
Dim i As Long
Dim PW As String
Dim WS As Worksheet
PW = InputBox("Enter password to protect all sheets:")
On Error GoTo MyErr
For Each WS In ActiveWorkbook.Worksheets
WS.Protect (PW)
Next
MsgBox i & " errors while protecting", vbInformation
Exit Sub
MyErr:
i = i + 1
Resume Next
End Sub
Now, I have a macro in the same module in which I would like to unprotect
the sheet with the password entered when protecting all the sheet, execute
some activities and then reprotect it with the same password, i.e. lets say I
i have the macro
Sub xxx()
Range("C4").Select
ActiveCell.FormulaR1C1 = "cc"
End Sub
Where and how do I enter the code?
I assume I need to make PW public or something (I'm quite new at VBA)
Secondly, I would like to apply the same thing as above to a worksheet event
that I have in a specific sheet
Any ideas?
Thanks