Toggle button linked cell changes

ottasight

New Member
Joined
Feb 15, 2009
Messages
47
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
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
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.xlsm
F
711/20/2022
Sheet8

VBA Code:
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
 

Attachments

  • Animation.gif
    Animation.gif
    18.1 KB · Views: 24
Upvote 0
VBA Code:
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
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top