+ Reply to Thread
Results 1 to 17 of 17

Populate Combobox using column headers

  1. #1
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Populate Combobox using column headers

    Hey Guys,

    I want to populate a combobox using the column headers (from row 1) on sheet1, i want the range to be dynamic, i've tried simply using a dynamic range which expands across rather than down with no luck.

    I think i need to transpose a dynamic range or something similar. Can i do this from entirely within vba, so i dont have to define a range within excel (less to go wrong?)

    Thanks in advance,

    Jack

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Populate Combobox using column headers

    What type of comboBox?

  3. #3
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Populate Combobox using column headers

    Just a normal combobox, from the toolbox, on a userform.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate Combobox using column headers

    Try
    Please Login or Register  to view this content.
    Last edited by royUK; 06-28-2010 at 08:01 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Populate Combobox using column headers

    I didnt read the above clearly... (deleted comment)
    Last edited by jberr; 06-28-2010 at 09:06 AM. Reason: incorrect

  6. #6
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Populate Combobox using column headers

    Sorry i didnt get all of it for some reason!

    Thats works perfectly roy thankyou, is there a method of removing the spaces? And is there a way of organsing the list alphabetically?

    Thankyou so much!
    Jack

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate Combobox using column headers

    What spaces? Is the list not continuous?

    Normally to arrange alphabetically you would sort the list, but not with a horizontal range. You could possibly gather all the values into a Collection, but that would be more complicated

  8. #8
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Populate Combobox using column headers

    Hi Roy,

    The list is continuous, however at the end of the list the white space goes on for a very long time...

    How would i go about sorting a horizontal range, without moving the positions of the columns? The idea of transposing keeps coming into my mind?

    Many thanks,
    Jack

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Populate Combobox using column headers

    Please Login or Register  to view this content.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate Combobox using column headers

    There should be no white spaces. Can you attach an example workbook?

  11. #11
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Populate Combobox using column headers

    Hi Roy,

    I just made you an majorly thinned down example workbhook, and it works fine with no spaces!? Typical! going to go over the orignal and see if i can see the problem..

  12. #12
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Populate Combobox using column headers

    Yep, i reopened once and it didnt work again, closed it and reopened and now it work every time.. ??
    Oh well, at least its solved!

    The alphabeticall ordering is impossible i take it?

    Thankyou for all your help,

    Jack

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate Combobox using column headers

    Try
    Please Login or Register  to view this content.
    Last edited by royUK; 06-28-2010 at 09:11 AM.

  14. #14
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Populate Combobox using column headers

    You are actually a genius, no idea how you did it, but it works perfectly, thankyou very much!!

    Thankyou again, its extremely generous of you to donate your time to people like me! You're a great bloke!

    Regards,
    Jack

  15. #15
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Populate Combobox using column headers

    Hi again,

    One more thing:

    How would i combine your previous sorting code with this (older version) (in order to populate 4 comboboxes the same way):

    Please Login or Register  to view this content.
    im trying to do it but with no luck, i dont know where the beginning and the the end parts of of the code above should go within your code?

    I just dont want to have to repeat that code 4 times for each individual comboboxe...



    Thanks,
    Jack
    Last edited by jberr; 06-28-2010 at 09:24 AM.

  16. #16
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Populate Combobox using column headers

    Try this
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    03-10-2010
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Populate Combobox using column headers

    Cheers Roy, thats works great, I couldnt of asked for more!

    Thanks again, your help was much appreciated.

    Jack

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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