ThatsEarElephant
New Member
- Joined
- Dec 27, 2016
- Messages
- 14
Hello! Before anybody asks me if I'm crazy for having a spreadsheet of 400 toggles (not to mention 2000 ComboBoxes), the short answer is "yes, I do need them!". But obviously I don't want to code every single item (which just bogs Excel up). Here is what I want to do:
I have a toggle button. When it's pressed, I want it to turn Green and caption "G". When it's released, I want it to turn Yellow and caption "Y". I know how to do this. Now, how do I make a group of these to all do the same thing (without UserForm, preferably). My script for one ToggleButton is this: ***Oh...please go easy on me. I'm new and I don't know anything about VBA syntax.
Sub ToggleButton1_Click()
If ToggleButton1.Caption = “G” Then
ToggleButton1.Caption =”Y”
Else
ToggleButton1.Caption = “G”
End If
If ToggleButton1.Value = True Then
ToggleButton1.BackColor = vbGreen
Else
ToggleButton1.Backcolor = vbYellow
End If
End Sub
I have a toggle button. When it's pressed, I want it to turn Green and caption "G". When it's released, I want it to turn Yellow and caption "Y". I know how to do this. Now, how do I make a group of these to all do the same thing (without UserForm, preferably). My script for one ToggleButton is this: ***Oh...please go easy on me. I'm new and I don't know anything about VBA syntax.
Sub ToggleButton1_Click()
If ToggleButton1.Caption = “G” Then
ToggleButton1.Caption =”Y”
Else
ToggleButton1.Caption = “G”
End If
If ToggleButton1.Value = True Then
ToggleButton1.BackColor = vbGreen
Else
ToggleButton1.Backcolor = vbYellow
End If
End Sub