Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

macro password problem

Status
Not open for further replies.

rbritton18

IS-IT--Management
Jul 20, 2007
62
0
0
CA
Below is macro. We just changed the password and it keeps giving us an error.

Sub SupervisorLock()
'
' SupervisorLock Macro
' Macro recorded 14/05/2002 by Marty Hrbolich
' This routine unprotects the sheet, locks the employee cells,
' then protects the entire sheet

' Unprotect the sheet
'Call UnprotectSheet
ActiveSheet.Unprotect Password:="clock" - error is here on this line

' select the employee cells, signature area
Range("A1:R32").Select
Range("R32").Activate
' lock the range of selected cells
Selection.Locked = True
Selection.FormulaHidden = False

'protect the sheet from editing
'Call ProtectSheet
ActiveSheet.Protect Password:="clock", DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub
Sub ProtectSheet()
'
' ProtectSheet Macro
' Macro recorded 14/05/2002 by Marty Hrbolich
'

'
ActiveSheet.Protect Password:="clock", DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
Sub UnprotectSheet()
'
' UnprotectSheet Macro
' Macro recorded 14/05/2002 by Marty Hrbolich
'

'
ActiveSheet.Unprotect Password:="clock"

End Sub

Sub SupervisorUnlock()
'this unlocks the employee entry cells and the signature area

'unprotect the sheet
ActiveSheet.Unprotect Password:="clock"

'select range of cells to unlock, employee and signature cells

Range("P8:Q22,F8:J22,L8:N22,Q28,Q32,R8:R22").Select
Range("Q28,Q32").Activate
' unlock the range of selected cells
Selection.Locked = False
Selection.FormulaHidden = False

'protect the sheet
ActiveSheet.Protect Password:="clock", DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub

 



Hi,

I can't help you with your password. You'll have to redo the sheet or get the correct password.

However, this is a problem as the ONLY cell that is being LOCKED is Range("R32")....
Code:
'   LOCK the employee cells, signature area
    with Range("A1:R32")
       .Locked = True
       .FormulaHidden = False
    end with
same with UNLOCK.

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks for your help SkipVought. I finally figured it out. I need to change the password in the protection part of the sheet. Once I changed that everything is working correctly with the macro. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top