+ Reply to Thread
Results 1 to 17 of 17

auto filling the combo box

  1. #1
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Racine, wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    225

    auto filling the combo box

    Hi all

    i was wondering how i can incorperate this code into my workbook

    Please Login or Register  to view this content.
    Thanks
    Keith
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: auto filling the combo box

    doubleclic on userform, then paste the code
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Racine, wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    225

    Re: auto filling the combo box

    Thanks for your response, but i have tried that and the comboboxes do not populate

    Please Help

    Keith

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: auto filling the combo box

    You don't have a sheet named Sheet1, explain better your goal.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: auto filling the combo box

    Hi, patel45,

    I would recommend you have a look at the workbook which has been attached before pasting in your thoughts of what might be your solution without testing what you are answering on the file where you would have noticed the different names for the comboboxes.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  6. #6
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Racine, wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    225

    Re: auto filling the combo box

    thanks for responding

    ok here it is, the original post attachment new1.xls does not populate the names when the form is activated, so i made a sample
    workbook called userform.xls, and some nice person answered with the code below.
    Please Login or Register  to view this content.
    so i copied it into the workbook called userform.xls, and it works perfect, i can change the name to any name right before
    i activate the form, and it works perfect.

    So i copied and pasted it into the workbook called new1.xls and tried to change some things like the name of the comboboxes,
    sheet names, the 1 to 6, to 3 to 8, and had no luck making it work, i'm just new to excel and asking for help, i'll attach both
    workbooks so you can see how good the code above works in userform.xls workbook. i hope i explained myself a little bit better
    this time.

    Thanks
    Keith
    Attached Files Attached Files

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: auto filling the combo box

    Hi, Quicksnot,

    as long as you only use CombBoxes that are named cmb1 to cmb6 there is no problem with the code that you have but if you alter the names of the boxes to read cmb1 to 3 as well p_cmb1 to p_cmb3 you would need to adjust the code to find the proper controls (not loop from 1 to 6 but from 1 to 3 and adjust the names as well).

    You may delete the RowSources for the ComboBoxes as well as these should be set by code (if you want to work with the UserForm for multiple sheets). What I didnīt pick up until now is how win and loss will be distributed, you may have to adjust the code there.

    Code goes behind the UserForm (Iīve taken the workbook from the opening post as reference):
    Please Login or Register  to view this content.
    Ciao,
    Holger

  8. #8
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Racine, wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    225

    Re: auto filling the combo box

    Thanks HaHoBe

    but unfortunately everything I tried was unsuccessful changing combo boxes, I guess I need to start with getting the names in 1st which
    was successful, then get the rest of the code to do what it already does.

    Thanks
    Keith

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: auto filling the combo box

    Hi, Keith ,

    your anser leaves me guessing if you have succeeded in finding a way to solve your problem or not.

    The code you put it canīt run (I mentioned the reason to be the different CB-names) if put behind the userform while the Activate-event I published should get the ComboBoxes to show the names from each sheet where the UserForm will get started.

    I would prefer not to fill the ComboBox on initializing or activating the UserForm but when the CombBox gets the focus and holding all names which are currently not being used in other comboboxes (which would leed to use AddItem and a loop).

    Regarding the code to put the results in: in my code there is an error as only the column to write into for the first CB is taken and used as well for teh second one (no matter how may entires there may be after taht coilumn).

    Ciao,
    Holger

  10. #10
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Racine, wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    225

    Re: auto filling the combo box

    Thanks HaHoBe, I'm sorry but I'm not very good with code at all, people here are awesome at it, I keep trying to change things to get it to work, but
    can't get the comboboxes to populate at all, the program works great except for that tiny piece of the puzzle.

    Thanks
    Keith

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: auto filling the combo box

    Hi, Keith,

    I assigned a shortcut for bringing up the UF on every sheet except for Stand: CTRL+SHIFT+D.

    Altered code in Module9:
    Please Login or Register  to view this content.
    I only inserted the part for populating the comboboxes behind the UserForm.

    Please check the attachment and see if it works for you.

    Ciao,
    Holger
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Racine, wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    225

    Re: auto filling the combo box

    Thanks for responding HaHoBe

    I saved the EF989590.xls to desktop, it opens on team3, used ctrl shift D, and the userform1 pops up, but nothing populates the userform
    am I doing something wrong?

    Thanks
    Keith

  13. #13
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Racine, wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    225

    Re: auto filling the combo box

    I have a question about the forms, is it possible to use the userform that just picks up the names, with this code
    Please Login or Register  to view this content.
    and add a command button that will activate form 2 and hide form 1, but copy whats in the comboboxes to form2 and then let the
    code work its magic, just s thought.

    Thanks
    Keith

  14. #14
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: auto filling the combo box

    Hi, Keith,

    just for me to understand:
    and the userform1 pops up, but nothing populates the userform
    What do you expect the code to do? Are the 6 ComboBoxes filled with the names from A3 to A19? Do you receive a run-time error? What else do you expect the UserForm to show?

    Regarding your second post:
    No, the same has been asked by you in the opening post. There are still only cmb1 to cmb3 on the form I use, any value greater than 3 will cause a run-time error.

    Ciao,
    Holger

  15. #15
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Racine, wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    225

    Re: auto filling the combo box

    ok earlier post has 2 excel books, the userform.xls is what I would like to happen in the new1.xls

    the "new1.xls" userform1 works perfect, don't want anything to change, except to incorporate the way
    "userform.xls" populates the comboboxes, is that possible?, if not, I will try to figure another way with
    maybe textboxes or something, the reason for the comboboxes, is so that the players may play the same 6
    players or maybe subctitute someone that week player 7 thru 17 "subs" 1 thru 6 are the main players each week.
    I just can't seem to figure out how to populate the comboboxes when activated, I don't want to use the drop down
    if I don't need to, 95% of the teams will play the same 6 players, so if their names are already there, I only have to
    click on an option button that matches how many games they won 0,1,2, or 3 and the score is inputted.

    if this isn't possible please let me know and I will attempt to figure out another way.

    Thanks
    Keith

  16. #16
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: auto filling the combo box

    Hi, Quicksnot,

    I cut off the RowSource for all ComboBoxes and adjusted ComboBox2 to be filled when you enter the dropdown (UserForm11):
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Racine, wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    225

    Re: auto filling the combo box

    thanks HaHoBe, but I must be doing something wrong, or explaining it wrong, I don't need anything done to the userfom workbook, I
    just need what it does to the workbook below.

    Thanks
    Keith
    Attached Files Attached Files

+ 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 yay_excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2011, 01:38 PM
  2. 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
  3. Filling a combo box via macro
    By TheNavigator in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-01-2007, 01:50 PM
  4. Auto-Filling Related Combo Box Entries
    By merritts in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2006, 02:43 PM
  5. Auto Protecting cells & auto filling date
    By ccarmock in forum Excel General
    Replies: 7
    Last Post: 09-30-2005, 05:05 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