ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Toggle Buttons (https://www.excelbanter.com/excel-programming/361635-toggle-buttons.html)

Bill

Toggle Buttons
 
I have a form with 10 toggle buttons. Each toggle button uses the same code.
How can I change the code so that is uses one piece of code instead on ten
sets of code.

Private Sub ToggleButton11_Click()
If ToggleButton11.Value = True Then
ToggleButton11.Caption = " "
ToggleButton11.BackColor = RGB(0, 255, 0)
Else
ToggleButton11.Caption = " "
ToggleButton11.BackColor = RGB(255, 0, 0)
End If
End Sub

Thanks Bill

Tom Ogilvy

Toggle Buttons
 
Use the same method as shown here
http://www.j-walk.com/ss/excel/tips/tip44.htm

for handling multiple commandbuttons.

--
Regards,
Tom Ogilvy


"Bill" wrote:

I have a form with 10 toggle buttons. Each toggle button uses the same code.
How can I change the code so that is uses one piece of code instead on ten
sets of code.

Private Sub ToggleButton11_Click()
If ToggleButton11.Value = True Then
ToggleButton11.Caption = " "
ToggleButton11.BackColor = RGB(0, 255, 0)
Else
ToggleButton11.Caption = " "
ToggleButton11.BackColor = RGB(255, 0, 0)
End If
End Sub

Thanks Bill



All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com