Hi All
I have a spreadsheet with a row of Toggle Buttons. The toggle buttons are to indicate if a task has been completed. When clicking the button it says 'YES' and using conditional formatting, turns the whole row green.
I have some VBA attached to the toggle button to determine the colour when true of false, see below:
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
ToggleButton1.BackColor = RGB(173, 219, 123)
ToggleButton1.Caption = "Yes"
Else
ToggleButton1.BackColor = RGB(255, 204, 204)
ToggleButton1.Caption = "No"
End If
End Sub
My question is this. When I add another toggle button, I copy the same code into VBA but have to edit the toggle button name to ToggleButton2, but as you can see, this has to be done 6 times in the code. I want to keep adding to the list of tasks but it takes ages to edit the code each time.
Is there a way to attach the VBA code to a new toggle button and have the name automatically increment each time?
Help gratefully received.
I have a spreadsheet with a row of Toggle Buttons. The toggle buttons are to indicate if a task has been completed. When clicking the button it says 'YES' and using conditional formatting, turns the whole row green.
I have some VBA attached to the toggle button to determine the colour when true of false, see below:
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
ToggleButton1.BackColor = RGB(173, 219, 123)
ToggleButton1.Caption = "Yes"
Else
ToggleButton1.BackColor = RGB(255, 204, 204)
ToggleButton1.Caption = "No"
End If
End Sub
My question is this. When I add another toggle button, I copy the same code into VBA but have to edit the toggle button name to ToggleButton2, but as you can see, this has to be done 6 times in the code. I want to keep adding to the list of tasks but it takes ages to edit the code each time.
Is there a way to attach the VBA code to a new toggle button and have the name automatically increment each time?
Help gratefully received.