+ Reply to Thread
Results 1 to 16 of 16

filling up values in a combo box

  1. #1
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2016
    Posts
    270

    filling up values in a combo box

    Hi Alll

    I have a combo box on sheet 2 . I want to fill this with the values from sheet1 range("a1:a50"). how to do this.
    or is it better to use
    A list box to a range and populate values.

    In either of the above two scenarios. can we type a part of the text and get those values. Example there 50 countries when i type in "H" can it show me in the dropdown where countries name start with "H". Is this possible in combox box / list values / list box

    Is it always better to use combox box / list box on userform rather them placing on a sheet and playing with the code.

    Many thanx for your help
    Never confuse a single defeat to the final defeat.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: filling up values in a combo box

    Yes, you can use a ComboBox. In the properties window of the ComboBox, set the RowSource to the sheet# and range ('Sheet1'!A1:A50). As far as the typing "H" and all "H" countries show, I don't know how to do that. But, I do know that when you type "H" it will bring up the 1st country that starts with "H" and the next one each time you type (hit) "H" after that.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: filling up values in a combo box

    In continuation to the above when i continue to select a value in the combo box to check the value in column (ex:3/4 so on) using vlookp. why does it throw the errors "n/a" below is the code and the workbook.

    ab1.png


    Please Login or Register  to view this content.
    Book1.xlsm
    Last edited by grkchakri; 03-21-2015 at 03:06 PM.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: filling up values in a combo box

    Hi grkchakri

    You've attached a Picture...can't work with that...please attach the File (WITH EXISTING CODE).
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: filling up values in a combo box

    i did attach the book now.

  6. #6
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: filling up values in a combo box

    Question....You have Dim z as string, but z is not used in the code....how come?

  7. #7
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: filling up values in a combo box

    Generally i have a habit of keeping some variables ready, though i might /might not use them. Z has got nothing to do in the code, u can use it if you want to alter the code

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: filling up values in a combo box

    Hi gmr4evr1

    I see you're back on line...I'll leave this to you as you're been on it and are following it.

    Please note, the OP is using VLookUp which requires Data to be sorted in ascending order.

  9. #9
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: filling up values in a combo box

    Howdy John,

    I am kind of lost on this one. When I ran the code, it would return the month for certain countries, others would return the correct #, and still others would return a number that had nothing to do with that country. I never did get it to return a value of N/A though.

    I did try using z in the code in various places, but the only change it ever made was returning a blank in e14.

  10. #10
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: filling up values in a combo box

    Yes if i understood it is right
    1) when text values are searching through Vlookup it should be in ascending order. Not nesccary when you are using numbers as you were look up value
    2) when text is involved is it better to use index and match functions

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: filling up values in a combo box

    @gmr4evr1

    I didn't either
    I never did get it to return a value of N/A though.

  12. #12
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: filling up values in a combo box

    Few things....

    1) You have left the last argument in Vlookup function, it should be 0 or false for an exact match.

    2) Why not to use a simple drop down list through data validation in a cell and referencing that cell in the formula, what is the need of a combobox placed on the sheet?

    3) If you are trying to get a value from the range C4:N11 based on country and month, index/match would be the right choice.

    4) Even if you use index/match, where is the month criteria placed on the sheet? I don't see any drop down for months.

    Probably you need to explain your requirement correctly.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  13. #13
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: filling up values in a combo box

    @grkchakri

    Your Lookup is text...x is text
    Please Login or Register  to view this content.

  14. #14
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: filling up values in a combo box

    @grkchakri
    Adding a 0 to this line does make a big difference (credit to sktneer)
    Please Login or Register  to view this content.
    Although I'm not sure if its returning the correct value for New York, but the others seem to be correct

  15. #15
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: filling up values in a combo box

    i Think the problem was first the values should be in ascending order when the value is in text format (Though i am not sure y) and added in the fourth parameter 0 for an exact match and i was able to get the values for the month jan and so on

    sktneer: I was trying to understand and check how to use a combox with vlookup and vlookup value being text.
    As u said a data validation simple one or index/match is the best i agree.

    Thank you guys (gmr4evr1,jaslake,sktneer) for your suggestions. Below is the code where it worked to give required info.

    Please Login or Register  to view this content.
    Last edited by grkchakri; 03-22-2015 at 12:11 AM.

  16. #16
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: filling up values in a combo box

    You're welcome, glad its working for you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Filling combo box
    By nmg1960 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-04-2014, 09:22 AM
  2. Filling Combo boxes based on the value of one combo box
    By KSChan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-01-2014, 12:48 AM
  3. Filling Combo Box
    By yay_excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2011, 01:38 PM
  4. Filling a combo box from the spreadsheet
    By rob0r in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2009, 10:35 AM
  5. Filling a combo box via macro
    By TheNavigator in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-01-2007, 01:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1