I'm working on a simple sports stat tracker. I'm using ActiveX buttons to track player fouls. I'd like to be able to see at a glance what fouls were in the first half vs the second half. Here's the VBA code I've patched together so far:
Private Sub CommandButton2_Click()
Dim x As Integer
For x = 1 To 392
If OLEObjects("ToggleButton" & x).Object.Value = True Then
OLEFormat("ToggleButton" & x).Object.Font.Color = vbRed
End If
Next x
End Sub
Basically, by pressing CommandButton2, the macro needs to check each button (yes, there's 392 of them) to see if it has already been pressed (= True) and, if so, change the font color to red. Right now, when I click CommandButton2 I get "Compile Error: Sub or Function not defined." Using Excel 2013 on PC, if that helps.
Thank you in advance!
Private Sub CommandButton2_Click()
Dim x As Integer
For x = 1 To 392
If OLEObjects("ToggleButton" & x).Object.Value = True Then
OLEFormat("ToggleButton" & x).Object.Font.Color = vbRed
End If
Next x
End Sub
Basically, by pressing CommandButton2, the macro needs to check each button (yes, there's 392 of them) to see if it has already been pressed (= True) and, if so, change the font color to red. Right now, when I click CommandButton2 I get "Compile Error: Sub or Function not defined." Using Excel 2013 on PC, if that helps.
Thank you in advance!