I'm using Excel 2000 and VBA. I have the following method that runs
when I change the value of a certain ComboBox ActiveX control:
Private Sub MyComboBox1_Change()
If MyComboBox1.Value = "Please Select" Then
MyComboBox1.BackColor = &H80FFFF
Else
MyComboBox1.BackColor = &HFFFFFF
End If
End Sub
I have about 12 of these methods for 12 different combo boxes. I'd
like to replace them all with something a little simpler:
Private Sub MyComboBox1_Change()
SetColor(MyComboBox1)
End Sub
Private Sub SetColor (cbox As ComboBox)
If MyComboBox1.Value = "Please Select" Then
MyComboBox1.BackColor = &H80FFFF
Else
MyComboBox1.BackColor = &HFFFFFF
End If
End Sub
However, this does not work. I get an error that reads: "Run-time
error '424': Object required."
What am I doing wrong? Also, rather than calling
"SetColor(MyComboBox1)", is there a way to reference the "current"
combo box using a variable similar to "this" in Java?