Return CheckBoxes.LinkedCell address VBA
<p>I use the following code to automatically generate a new checkbox and link a cell to it:</p>

<pre><code>ActiveSheet.CheckBoxes.Add().LinkedCell = Selection.Address
</code></pre>

<p>I want to create another <code>sub</code> which should change the background color of the <code>.LinkedCell</code> cell of the checkbox when the checkbox is checked (blue) or unchecked (red). I will have about 200 checkboxes in the worksheet.</p>

<p>Is there a way to get/return the <code>.LinkedCell</code> address of the currently checked/unchecked checkbox so that the <code>sub</code> can change the background color of that cell?</p>

<p>For example let's presume that the <code>.LinkedCell</code> is the cell in which the checkbox was initially placed. This would be the initial status of each checkbox:</p>

<p><a href="https://i.stack.imgur.com/NQCNJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NQCNJ.jpg" alt="enter image description here"></a></p>

<p>and this would be the result after the user checks/unchecks the checboxes:</p>

<p><a href="https://i.stack.imgur.com/ATvYa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ATvYa.jpg" alt="enter image description here"></a></p>

<p>until now I used this code to change the background color of the checkbox itself. But I don't want that, I want to change the color of the <code>.LinkedCell</code>.</p>

<pre><code>Sub SetMacro()
    Dim cb
    For Each cb In ActiveSheet.CheckBoxes
        If cb.OnAction = "" Then cb.OnAction = "CheckedUnchecked"
    Next cb
End Sub
</code></pre>

<p>and </p>

<pre><code>Sub CheckedUnchecked()
    With ActiveSheet.Shapes(Application.Caller).DrawingObject
        If .Value = 1 Then
            .Interior.ColorIndex = 5
        Else
            .Interior.ColorIndex = 3
        End If
    End With
End Sub
</code></pre>