Soup to nuts listbox help needed

J

Jim

I've created a userform before but it was a long time ago and I don't
have it or the resources I used to create it available, so I need some
help.

The goal is to have a userform open upon clicking on a custom toolbar
button that will have a listbox with "English" names for web pages
whose URL is dynamic (www.mysite.com?page=4&dept=74&lang=-1). When a
user selects the English name from the dropdown, it will be used to
reference both the URL (for a web query - already written and working)
and a worksheet that contains data for the webpage. The macro is in a
hidden workbook, so I do have the option of creating a table to lookup
the values for the English name.

I have the userform created with the listbox and buttons on it I need,
but I don't know how to load the English names into the listbox, have
the listbox pop up, and then how to have the existing macro reference
the needed values based on the listbox choice.

TIA,
Jim
 
T

Tom Ogilvy

Perhaps this will give some ideas.

in a General Module:

Sub Showform()
Userform1.show
End Sub

in the Userform1 module

Private Sub Userform_Initialize()
set rng = Workbooks("Data.xls").Worksheets("MyNames").Range("A1:A10")
Listbox1.List = rng.Value
End Sub

Private Sub CommandButton1_Click()
if Listbox1.ListIndex <> -1 then
sEnglishName = Listbox1.Value
Application.Run "Data1.xls!Macro1",sEnglishName
' work on pages using sEnglishName
End if
End Sub


---
in the workbook Data1 you would have a macro named macro1

Sub Macro1(sName as String)
' execute web query using sName
End Sub
 
J

Jim

Tom,

That's great - this will get me started (although I may be back with
more questions).

Thanks,
Jim
 

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

Top