I have a dilemma - I need a list box that outputs the number of its selection, and can be toggled visible/not visible.
The Form Control ListBox outputs the number of the option selected (In a list of states, selecting "Alaska" returns "2"). However, I cannot seem to make my CommandButton toggle its visibility.
The ActiveX Control ListBox outputs the selection itself (Selecting Alaska returns"Alaska") and I cannot seem to run formulas based on it (=(A1="Alaska") returns FALSE instead of TRUE). I can, however, toggle its visibility with a command button:
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "By State" Then
StateList.Visible = True
CommandButton1.Caption = "Country Wide"
ElseIf CommandButton1.Caption = "Country Wide" Then
StateList.Visible = False
CommandButton1.Caption = "By State"
End If
End Sub
I tried that code with a Form ListBox (I determined its name by assigning it a macro). "ListBox3.Visible = True" results in an error: Run-time error '424': Object required.
So - I need one of the following (although learning them all is always awesome, too):
- A way to make my ActiveX control output the number of its selection
- A formula that can take the ActiveX selection into account (a boolean on the "State" selected)
- Or a way to modify my above code to toggle the visibility of a Form ListBox
Thoughts?
Bookmarks