Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default List Box Head-Scratcher

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default List Box Head-Scratcher

If all you need to do is place the value on A1 go to the listbox properties
and on the tab Categorized, select the data category and Place A1 where the
RowSource property is, this should place whatever the user selects on A1.
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default List Box Head-Scratcher

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default List Box Head-Scratcher

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default List Box Head-Scratcher

James, I usually use the ListBox1_Click method to do what you are trying with
the ListBox1_Change and have not had any problems with the UserForm
unloading. Maybe I missed something?

"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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default List Box Head-Scratcher

Michael, thannks for your reply. However, that puts the value of A1 in the
listbox. It does not put the value of the listbox in A1. James

"Michael" wrote in message
...
If all you need to do is place the value on A1 go to the listbox
properties
and on the tab Categorized, select the data category and Place A1 where
the
RowSource property is, this should place whatever the user selects on A1.
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"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





  #7   Report Post  
Posted to microsoft.public.excel.programming
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





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default List Box Head-Scratcher

Whiz, If I change ListBox1_Change to ListBox1_Click, it still crashes, so
I'm going to go with Vergel's solution. Thanks for replying, though.
James

"JLGWhiz" wrote in message
...
James, I usually use the ListBox1_Click method to do what you are trying
with
the ListBox1_Change and have not had any problems with the UserForm
unloading. Maybe I missed something?

"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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a template to double check Lottery scratcher tickets? lkn4bearbud Excel Discussion (Misc queries) 1 April 18th 09 08:08 AM
over my head James Excel Discussion (Misc queries) 5 June 24th 08 10:06 AM
RibbonX and a "macro may not be available" head-scratcher [email protected] Excel Programming 5 February 14th 07 08:03 PM
In over my head again BOBODD Excel Programming 0 December 6th 06 02:33 AM
Over my head on this one... ChuckF Excel Worksheet Functions 1 April 6th 06 10:57 PM


All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"