Userform listbox selection populates two text boxes

silvertyphoon1

New Member
Joined
Nov 14, 2010
Messages
18
The userform contains multiple option buttons, a listbox and two text boxes. When I select an option button the listbox populates with certain items from a source on the “Lookup” sheet. That part works without issues. What I’m looking for is the following:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
1. When an item in the listbox is selected data populates the two text boxes on the userform with information from the “Lookup” sheet.<o:p></o:p>
The first textbox must come from the corresponding row in the E column, the second must come from the same row from the F column. <o:p></o:p>
So when a user clicks say option 1 for lights, the listbox will display different models. When the user selects the correct model the textbox labeled length will display the bulb length and the textbox labeled wattage will display the correct wattage for that bulb. <o:p></o:p>
This is a little lookup userform to find information. <o:p></o:p>
Thanks again<o:p></o:p>
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,
Try using the vlookup function apon the listbox items

eg:
Code:
dim asd as variant
dim lengtha as variant
dim watt as variant
 
if listbox1.value = "light1" then
 
asd = listbox1.value
lengtha = Application.VLookup(asd , Worksheets("Sheet1").Range("A2:H9999"), 3, False)
'change range accordingly and the 3 is the coloum you wish the result for
watt = Application.VLookup(asd , Worksheets("Sheet1").Range("A2:H9999"), 4, False)
 
textbox1.text = lengtha
textbox2.text = watt 
 
elseif listbox1.value = "light2" then
 
asd = listbox1.value
lengtha = Application.VLookup(asd , Worksheets("Sheet1").Range("A2:H9999"), 3, False)
'change range accordingly and the 3 is the coloum you wish the result for
watt = Application.VLookup(asd , Worksheets("Sheet1").Range("A2:H9999"), 4, False)
 
textbox1.text = lengtha
textbox2.text = watt 
 
etc etc
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top