How to get out of a listbox?

B

Bobby

Hi! Need a little help please.
Question, how do I terminate/close the listbox after the user made one
selection?
My code filling up a the listbox and calling a Userform1
Thank's ahead for any pointers.


Sub slist()
i = 1
For Each ws In Worksheets
UserForm1.ListBox1.AddItem (Worksheets(i).Name)
i = i + 1
Next ws


UserForm1.Show
End Sub


Userform1 code:----------------------------------------


Private Sub ListBox1_Click()
Sheets(UserForm1.ListBox1.Value).Select
End Sub
 
B

Bob Phillips

Not sure I have got the problem, but maybe try

Sub slist()
i = 1
Userform1.Listbox1.Clear
For Each ws In Worksheets
UserForm1.ListBox1.AddItem (Worksheets(i).Name)
i = i + 1
Next ws


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

Bobby

Hi Bob! What I am trying to do is when the listbox appers I would like
to see:
1. The selected Sheet
2. Close the Listbox
Thank's for your help!
 
C

Chris Lavender

Code module for UserForm1

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
myval = ListBox1
Sheets(myval).Select
Unload Me
End Sub

HTH
Chris Lav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top