Hello.
I want to make a dropdown list in a UserForm.
I have created the drop down list, but I do not know how to get data from the excel sheet in the list and how to find out which of the numbers in the list, the user has clicked.
Hello.
I want to make a dropdown list in a UserForm.
I have created the drop down list, but I do not know how to get data from the excel sheet in the list and how to find out which of the numbers in the list, the user has clicked.
There are a couple of ways to fill your Combobox.
First there is a property called "row source" that needs a range to point it to the data that you want to use in the Combobox. (Easiest)
\1
Second you can leave the row source blank and use the .AddItem method where you can fill the Combobox each time the UserForm is initiated. (always has the updated info)
....and there is another 3rd way that is escaping me at the moment, maybe one of the other forum members will chime in and jog my memory.
EDIT:can you post an example workbook?, it helps someone like me who isn't all that versed in VBA to figure out what is going on with the problem that you describe.
Last edited by jwright650; 01-26-2011 at 08:51 AM. Reason: added picture of Row Source in Properties Window
Life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
John Wright
"]can you post an example workbook?, it helps someone like me who isn't all that versed in VBA to figure out what is going on with the problem that you describe"
Take a look at this
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
Here is yo0ur file with the row source filled in (A1:A5) - see properties window, scroll down to "row source"
Also added some code to your command button to enter the number chosen into cell B1
First, thanks for the great help!
I have another question.
Now I have changed a bit on the file RoyUK made, and I want the text to come in the dropdown list, but number to the right of the text is pasted into cell C1 (so if you choose "One"in the dropdown list, it should write "1 "C1
Try this, I've amended the code to display two columns in the combobox & use the ComboBox's List property
Or you can use the same settings as the first example
Please Login or Register to view this content.
Last edited by royUK; 01-26-2011 at 01:49 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks