Harley78
Electrical
- May 8, 2007
- 77
Currently I have anywhere from 5-32 command buttons on each tab (worksheet)which I have 32 worksheets. Each Command Button Will change color if selected as well as enter data in a cell that I specified. As well As if selected again...... See current code,
Private Sub CommandButton38_Click()
If CommandButton38.BackColor = RGB(255, 255, 0) Then_CommandButton38.BackColor = RGB(255, 255, 255) Else_CommandButton38.BackColor = RGB(255, 255, 0)
Range("A37").Value = 1
If CommandButton38.BackColor = RGB(255, 255, 255) Then _Range("A37").Value = ""
End Sub
So my question is, Does anyone have any suggestion how I could condence this action instead of having to copy or write this code over and over?
Private Sub CommandButton38_Click()
If CommandButton38.BackColor = RGB(255, 255, 0) Then_CommandButton38.BackColor = RGB(255, 255, 255) Else_CommandButton38.BackColor = RGB(255, 255, 0)
Range("A37").Value = 1
If CommandButton38.BackColor = RGB(255, 255, 255) Then _Range("A37").Value = ""
End Sub
So my question is, Does anyone have any suggestion how I could condence this action instead of having to copy or write this code over and over?