Hello Guys,
I found the following code on this forum
I tried to change it to
But it is not working. What should I be doing to make it work? I want to highlight the whole four cells i.e. from -4 to -1.
Thanks for your help.
Asad
I found the following code on this forum
Public Sub CB_Read()
Dim oShape As Shape
Dim oTarget As Range
Set oShape = ActiveSheet.Shapes(Application.Caller)
'Change the "Offset(Row,Column)" in the next line to whatever cell is desired for the status of the checkbox.
Set oTarget = oShape.TopLeftCell.Offset(0, -4)
If oShape.ControlFormat.Value = xlOff Then
oTarget.Value = 0
Else
oTarget.Value = 1
End If
End Sub
I tried to change it to
Public Sub CB_Read()
Dim oShape As Shape
Dim oTarget As Range
Set oShape = ActiveSheet.Shapes(Application.Caller)
'Change the "Offset(Row,Column)" in the next line to whatever cell is desired for the status of the checkbox.
Set oTarget = Range(oShape.TopLeftCell.Offset(0, -4),oShape.TopLeftCell.Offset(0, -1))
If oShape.ControlFormat.Value = xlOff Then
oTarget.ColorINdex = xlNone
Else
oTarget.ColorIndex = 20
End If
End Sub
But it is not working. What should I be doing to make it work? I want to highlight the whole four cells i.e. from -4 to -1.
Thanks for your help.
Asad