+ Reply to Thread
Results 1 to 8 of 8

Change Combobox in userform

  1. #1
    Registered User
    Join Date
    03-26-2019
    Location
    Spain
    MS-Off Ver
    Office 2010
    Posts
    4

    Question Change Combobox in userform

    Hi VBA users!

    Please I need some help to solve a problem that I have with an UserForm. I explain the situation.

    I have more than 20 combobox into the Userform which have the same options (Yes, No, N/A)

    I tried to create a class module but it doesn't work.

    The code:

    Into the UserForm:
    Please Login or Register  to view this content.
    Into class module (the value in red generates the error)

    Please Login or Register  to view this content.
    Basically I want to call this class module each time that I need to use this code to avoid repeat for each combobox.

    If you have the solution or better idea, I will appreciate it a lot.

    Note: please explain for rookies, I am not advanced for Macros, I am trying to learn, but this kind of explanation don't appear on Internet ^^

    Thanks!
    Last edited by davesexcel; 03-26-2019 at 12:45 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Change Combobox in userform

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

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

    Re: Change Combobox in userform

    If you assign this to each combobox.
    Keep it all in the same userform module.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Change Combobox in userform

    This is the Method I use.

    Number your Comboboxes 1 to 20

    Then a simple piece of code is all you need.

    I find it boring creating 20 small pieces of code so I use a Macro to write the 20 pieces of code for me.

    Click on the button on the attached file.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-26-2019
    Location
    Spain
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Change Combobox in userform

    Thanks mehmetcik for your answer, but I have a specific name for each combobox. This method works in all cases?

    Thanks a lot!
    Last edited by ninjaspeed; 03-27-2019 at 03:30 AM.

  6. #6
    Registered User
    Join Date
    03-26-2019
    Location
    Spain
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Change Combobox in userform

    Thanks for your answer davesexcel

    Only one question. Could this method generate problems using "ActiveControl"? I am a little scared working with "selections". I repeat that I am very rookie ^^

    Thanks!

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

    Re: Change Combobox in userform

    What are you selecting?

    Clicking a control makes that control the active control.

  8. #8
    Registered User
    Join Date
    03-26-2019
    Location
    Spain
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Change Combobox in userform

    Interesting,
    If you could supply a sample workbook with the userform.

    mehmetcik's solution is more direct as it actually uses the combobox (Name)number.
    Last edited by davesexcel; 03-27-2019 at 11:10 AM.

+ 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. ComboBox in USERFORM used to change which sheet output goes
    By InvalidTxtString in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2016, 06:31 PM
  2. [SOLVED] Userform: Change Combobox list based on a second ComboBox selection
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-11-2016, 03:45 PM
  3. Userform Combobox to populate form: Can I change the order of the columns in the combobox?
    By CraigWiggins in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2014, 12:14 PM
  4. [SOLVED] cannot change userform combobox range error 457
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-08-2014, 05:22 PM
  5. Change Userform Label based on ComboBox Selection
    By rbyrd023 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-02-2014, 09:25 AM
  6. [SOLVED] Change Labels in Userform based on selection in ComboBox
    By johnw993 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 01-03-2013, 10:52 PM
  7. [SOLVED] UserForm ComboBox Change Event Question
    By tja1964 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2012, 07:21 PM

Tags for this Thread

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