OfficeUser
Well-known Member
- Joined
- Feb 4, 2010
- Messages
- 544
- Office Version
- 365
- 2016
- Platform
- Windows
I am using this bit of code to perform a few things:
I receive an error: 'Unable to set the locked property of the range class' at this line:
If I remove the affected line then my code runs fine from beginning to end. Any suggestions on what may be the issue? Thanks.
Code:
Sub Initialize()
Dim WS As Worksheet, shp As Shape
For Each WS In Worksheets
For Each shp In WS.Shapes
If shp.Name = "lblGreen" Then shp.Visible = False
If shp.Name = "lblRed" Then shp.Visible = True
WS.Unprotect "password"
WS.Range("AW10:BA10").Value = "80"
WS.Range("S10:W10").Value = "80"
WS.Range("AW10:BA10").Locked = True
WS.Range("S10:W10").Locked = True
Next shp
WS.Protect "password"
Next WS
End Sub
I receive an error: 'Unable to set the locked property of the range class' at this line:
Code:
WS.Range("S10:W10").Locked = True
If I remove the affected line then my code runs fine from beginning to end. Any suggestions on what may be the issue? Thanks.