N
NikkiBenz
My workbook has 14 worksheets (4 of them are data sheets and are hidde
to the user). Most of the sheets have command buttons to ope
userForms to capture data and run reports.
I want to protect all the sheets to prevent the user from messing wit
the formulas, etc. In all of the userform_Initialization events, I a
running a UnprotectSheets module and a ProtectSheets module o
UserForm_Terminate events.
The problem is that I'm getting 1004 Runtime errors when trying t
protect/unprotect certain sheets (does not happen on just one specifi
sheet). When I try to protect/unprotect manally on the sheet by goin
to Tools/Protection... the protect/unprotect option is greyed out. I
becomes available when I click somewhere in the worksheet and then
can proceed with the manual way or even the macro way. I think it ha
something to do with what's on focus in the sheet. I think the shee
loses the focus when the button is clicked. (If that makes sense)
So, I thought I could be clever by selecting or activating a cel
(range) in each worksheet before protecting/unprotecting, but I stil
get the runtime error. The sheets are password protected. I'
accessing the password via a constant field. But I know it's not
problem with the password.
Sub ProtectSheets()
Dim ws As Worksheet
For each ws in ActiveWorkbook.Worksheets
ws.Range("A1").Select
ws.Protect constPassword
Next ws
End Sub
The unprotectSheets looks the same other than ws.Unprotec
constPassword
Do you have any suggestions
to the user). Most of the sheets have command buttons to ope
userForms to capture data and run reports.
I want to protect all the sheets to prevent the user from messing wit
the formulas, etc. In all of the userform_Initialization events, I a
running a UnprotectSheets module and a ProtectSheets module o
UserForm_Terminate events.
The problem is that I'm getting 1004 Runtime errors when trying t
protect/unprotect certain sheets (does not happen on just one specifi
sheet). When I try to protect/unprotect manally on the sheet by goin
to Tools/Protection... the protect/unprotect option is greyed out. I
becomes available when I click somewhere in the worksheet and then
can proceed with the manual way or even the macro way. I think it ha
something to do with what's on focus in the sheet. I think the shee
loses the focus when the button is clicked. (If that makes sense)
So, I thought I could be clever by selecting or activating a cel
(range) in each worksheet before protecting/unprotecting, but I stil
get the runtime error. The sheets are password protected. I'
accessing the password via a constant field. But I know it's not
problem with the password.
Sub ProtectSheets()
Dim ws As Worksheet
For each ws in ActiveWorkbook.Worksheets
ws.Range("A1").Select
ws.Protect constPassword
Next ws
End Sub
The unprotectSheets looks the same other than ws.Unprotec
constPassword
Do you have any suggestions