Hi, im tryng to lock a range with offset.
I have error "Unable to set Locked property of Range Class error" 1004 on this code
The cell is a merged cell i tried also to put (0, -1) but i have the same error
LP is a variable
VBA Code:
Sub DCHK()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Dim chk As OLEObject
For Each chk In ActiveSheet.OLEObjects
If TypeName(chk.Object) = "CheckBox" And chk.Object.Value = False Then
If chk.TopLeftCell.Offset(0, 0).Value = LP Then
If chk.TopLeftCell.Offset(0, 1).Locked = False Then
chk.TopLeftCell.Offset(0, 1).Locked = True
End If
If chk.TopLeftCell.Offset(0, -2).Locked = False Then
chk.TopLeftCell.Offset(0, -2).Locked = True
End If
'chk.Visible = False
End If
End If
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
End Sub
I have error "Unable to set Locked property of Range Class error" 1004 on this code
VBA Code:
chk.TopLeftCell.Offset(0, -2).Locked = True
LP is a variable