OfficeUser
Well-known Member
- Joined
- Feb 4, 2010
- Messages
- 544
- Office Version
- 365
- 2016
- Platform
- Windows
I have a worksheet where shape changes color when a command button is clicked.
It works fine as-is. If I copy the worksheet then the shape name changes to something like "Oval16" or "Oval 4" thus causing my code to error.
Is there a way to keep this from happening? I don't have this issue with my command buttons so I am not seeing the difference here. Suggestions? 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
Is there a way to keep this from happening? I don't have this issue with my command buttons so I am not seeing the difference here. Suggestions? Thanks.