Thread: ListBox Value
View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Carrie_Loos via OfficeKB.com Carrie_Loos via OfficeKB.com is offline
external usenet poster
 
Posts: 116
Default ListBox Value

Thanks for all the info. Since I am realitively new to VBA without any formal
training some simple things can be lost so I apologize if I am asking a silly
question. The only code I could get to work was the suggestion you had
earlier. This is for a MultiList Box. I have somehow botched this up. I could
not get the option button to "unload" someone gave me this clear the option
button code which causes me a couple of problems 1) The option button never
shows "clicked" and 2) I have to re-click the option button after a list box
selection to get the code to run and show the selection in cell A1. I just
can't seem to get past this portion. Any suggestions?

Private Sub OptionButton41_Click()

ListBox1.RowSource = "Classes!Customer"

Range("A1") = ListBox1.Value
For i = 1 To ListBox1.ListCount - 1
Range("A2") = ListBox1.Selected(i)
Next

Dim ctrl As Control
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSForms.TextBox Then
ctrl.Value = ""
ElseIf TypeOf ctrl Is MSForms.OptionButton Then
ctrl.Value = False
End If
Next ctrl


End Sub

JLGWhiz wrote:
Yeah, I just wanted to illustrate the use of the index number. Guess I
should be more careful about syntax and structure.

For a single select listbox you can use the ListBox1.Value or the
ListBox1.Selected(index) syntax, (assuming ListBox1).

[quoted text clipped - 21 lines]

Rick


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1