View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Zone[_3_] Zone[_3_] is offline
external usenet poster
 
Posts: 373
Default List Box Head-Scratcher

Vergel, that works like a charm. Thanks! James

"Vergel Adriano" wrote in message
...
maybe like this:

Private bFormIsLoading As Boolean
Private Sub ListBox1_Change()
[a1] = Me.ListBox1
If Not bFormIsLoading Then
Unload Me
Else
bFormIsLoading = False
End If
End Sub

Private Sub UserForm_Initialize()
bFormIsLoading = True
Me.ListBox1.AddItem "Lions"
Me.ListBox1.AddItem "Tigers"
Me.ListBox1.AddItem "Bears"
Me.ListBox1 = "Bears"
End Sub


--
Hope that helps.

Vergel Adriano


"Zone" wrote:

I want this userform to put the value of the listbox in cell A1 as soon
as
the user makes a selection. Then I want the form to close. I finally
figured out it was the Unload Me that was causing the code to choke, so I
put in a Close button to unload the darn thing. But I don't like that.
How
can I make this work? TIA, James

Private Sub ListBox1_Change()
[a1] = Me.ListBox1
Unload Me
End Sub

Private Sub UserForm_Initialize()
Me.ListBox1.AddItem "Lions"
Me.ListBox1.AddItem "Tigers"
Me.ListBox1.AddItem "Bears"
Me.ListBox1 = "Bears"
End Sub