A simple VB Macro to change a list of Toggle Buttons color/caption once another button is clicked.

bubu71

New Member
Joined
Jan 30, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I have a list of 20-30 toggle buttons, I need a simple code that once one of the button is clicked the rest of the buttons will change color/caption and if one was
ToggleButton1.Value = True then it will change to ToggleButton1.Value = False (while the clicked one will change to True)
I have the following:
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
ToggleButton1.Caption = "Dan Active"
ToggleButton1.BackColor = RGB(0, 254, 0)
ToggleButton1.FontSize = 11
ToggleButton1.Font.Bold = True
ToggleButton1.ForeColor = RGB(0, 0, 0)
ToggleButton2.Value = False
ToggleButton2.Caption = "Michael"
ToggleButton2.BackColor = RGB(192, 192, 192)
ToggleButton2.FontSize = 11
ToggleButton2.Font.Bold = False
ToggleButton2.ForeColor = RGB(0, 0, 0)

Else
ToggleButton1.Caption = "Dan"
ToggleButton1.BackColor = RGB(192, 192, 192)
ToggleButton1.FontSize = 11
ToggleButton1.Font.Bold = False
ToggleButton1.ForeColor = RGB(0, 0, 0)
End If
End Sub

I dont want to repeat the BOLD section to all the buttons (each button has a different name) so Im looking for a simple code to do it as I need to repeat it to all the buttons I have.

thanks
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
These are activex controls on a sheet?
In the end, you want it so that only one can be depressed/selected at a time? Selecting one will unselect all the rest? Then why not use option buttons in a frame? Only one can be selected at any time if done properly.
 
Upvote 0

Forum statistics

Threads
1,214,868
Messages
6,122,005
Members
449,059
Latest member
mtsheetz

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