classicpcs
08-22-2014, 09:59 AM
I have an spread sheet where I created a toggle button linked to cell that when clicked it shows a check mark and turns green when clicked again it removes checkmark and turns red. Is there any code that will combine all the toggle buttons I want to create? What I am looking at now is coping the same code for each toggle button and then changing the values plus the cell. The code listed below is for one toggle button. Probably need over 100 to do the same thing. Thank you in advance!
Private Sub ToggleButton_Click()
If ToggleButton.Value = True Then
ToggleButton.BackColor = vbGreen 'green
Else
ToggleButton.BackColor = 255 'red
End If
If ToggleButton.Value = True Then
Range("B2").Interior.Color = vbGreen 'green
Range("B2").Value = "YES"
Else
Range("B2").Interior.Color = 255 'red
Range("B2").Value = "NO"
End If
If ToggleButton.Caption = Chr(254) Then
ToggleButton.Caption = Chr(168)
Else
ToggleButton.Caption = Chr(254)
End If
End Sub
Private Sub ToggleButton_Click()
If ToggleButton.Value = True Then
ToggleButton.BackColor = vbGreen 'green
Else
ToggleButton.BackColor = 255 'red
End If
If ToggleButton.Value = True Then
Range("B2").Interior.Color = vbGreen 'green
Range("B2").Value = "YES"
Else
Range("B2").Interior.Color = 255 'red
Range("B2").Value = "NO"
End If
If ToggleButton.Caption = Chr(254) Then
ToggleButton.Caption = Chr(168)
Else
ToggleButton.Caption = Chr(254)
End If
End Sub