OfficeUser
Well-known Member
- Joined
- Feb 4, 2010
- Messages
- 544
- Office Version
- 365
- 2016
- Platform
- Windows
This is the code that is triggered by a button to alert a user that two specific cells are active:
If the shape appears red then the cells are locked, when it is green, they are unlocked.
I tried to add this bit into the Workbook_Open event to make sure the two cells are locked and the shape is red when first opening the workbook but I get an error:
Problem is I receive a compile error: Sub or Function not defined. The highlighted word is 'Shapes'. Anyone know what I am missing? Thanks.
Code:
Private Sub lblChem_Click()
ActiveSheet.Unprotect Password:="password"
If Shapes("Oval 1").Fill.ForeColor.SchemeColor = 10 Then 'Red
Shapes("Oval 1").Fill.ForeColor.SchemeColor = 11
Range("AW10:BA10,S10:W10").Select
Selection.Locked = False
Range("AC5").Select
Else
If Shapes("Oval 1").Fill.ForeColor.SchemeColor = 11 Then 'Green
Shapes("Oval 1").Fill.ForeColor.SchemeColor = 10
Range("AW10:BA10,S10:W10").Select
Selection.Locked = True
Range("AC5").Select
End If
End If
ActiveSheet.Protect Password:="password"
End Sub
I tried to add this bit into the Workbook_Open event to make sure the two cells are locked and the shape is red when first opening the workbook but I get an error:
Code:
Private Sub Workbook_Open()
ActiveSheet.Unprotect.Password:="password"
If Shapes("Oval 1").Fill.ForeColor.SchemeColor = 11 Then 'Green
Shapes("Oval 1").Fill.ForeColor.SchemeColor = 10
Range("AW10:BA10,S10:W10").Select
Selection.Locked = True
Range("AC5").Select
End If
ActiveSheet.Protect Password:="password"
End Sub