# Toggle button linked cell changes



## ottasight (Nov 12, 2022)

Hi Need help with toggle button linked cell text. the linked cell contains a date. i need the true, false, #na not to appear in the linked cell. when button state is turned to true linked cell should be solid black, solid red when in a false state and when in the #na state yellow, with the date highlighted. the date in cell should not overwritten in any state. thanks for any help


----------



## PeteWright (Nov 13, 2022)

I don't get the point of linking a cell to the toggle button and besides, afaik a toggle button can only have two states: TRUE or FALSE, but nothing like N/A. Correct me if I'm wrong.

If I got you right, the cell with the date should change its color depending on the toggle button. Below is an example mini sheet and an animation of the button states changing the cell's background color.

Book1.xlsmF711/20/2022Sheet8

```
Private Sub ToggleButton1_Click()
   Dim rng As Range: Set rng = ThisWorkbook.ActiveSheet.Range("F7")
   If ToggleButton1.Value = True Then rng.Interior.ColorIndex = 1
   If ToggleButton1.Value = False Then rng.Interior.ColorIndex = 3
End Sub
```


----------



## ottasight (Jan 2, 2023)

Hi Pete, yes toggle buttons have three states check out the properties window "triple state"


----------



## shinigamilight (Jan 2, 2023)

```
Private Sub ToggleButton1_Change()
        If ToggleButton1.Value = True Then
        Range("A1").Interior.Color = vbBlack
        ElseIf ToggleButton1.Value = False Then
        Range("A1").Interior.Color = vbRed
        ElseIf IsNull(ToggleButton1.Value) Then
        Range("A1").Interior.Color = vbYellow
        End If
        
End Sub
```


----------

