hi,,
i had created a user form where i want to show the values in the listbox based on values from combobox.i had used the vlookupfunction to get so.I m getting an error.Is my syntax for the function incorrect..kindly tell me...
hi,,
i had created a user form where i want to show the values in the listbox based on values from combobox.i had used the vlookupfunction to get so.I m getting an error.Is my syntax for the function incorrect..kindly tell me...
Last edited by excelkeechak; 02-17-2012 at 09:54 PM.
THANKS
ExcelKeechak
I can find no formulas or anything in your workbook, just 3 plain columns of info. Did you upload the correct file?
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
Your VLOOKUP fomula wouldn't work even in a sheet, the Lookup value should be in the first column of the lookup table
Rename tab to be =Sheet1!$B$2:$B$6, note how the range is referred to in the code.
A better way would be to use![]()
Private Sub ComboBox1_Change() ListBox1.AddItem Worksheetfunction.VLookup(ComboBox1.Value, Range("tab"), 2, 0) End Sub
![]()
Private Sub ComboBox1_Change() ListBox1.AddItem Cells(ComboBox1.ListIndex + 2, 3).Value End Sub
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
Thanks mr.Roy..the second code works.but the list box is not cleared when a new selection is made in the combobox....?
It's a simple fix & you should check out control properties in the Object Browser if you want to learn VBA
![]()
Private Sub ComboBox1_Change() Listbox1.Clear Listbox1.AddItem Cells(ComboBox1.ListIndex + 2, 3).Value End Sub
thanks roy....
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks