You are currently viewing the Excel VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
I have 2 listboxes in Excel 2003. I populate one listbox with an external source (Access table using Get External data/database query) rangename is companies. No problem with the first listbox, but the second listbox would be populated based on the selected item in the first listbox. In essence, the second listbox would have multiple results when an item is selected in the first listbox. I have also brought the values from a second table using the same method to display the quotes (rangename is quotes)
What I need to be able to do is to populate listbox2 using a vlookup, but I cannot seem to get any results in listbox2.
Here is my code at this point:
Function Getquotevalues()
Dim rng As Range
Dim srchstr As String
srchstr = Me.lbcompanies.Value
Set rng = Range("Quotes")
Getquotevalues = Application.WorksheetFunction.VLookup(srchstr, rng, 2, False)
End Function