+ Reply to Thread
Results 1 to 10 of 10

Run Code based on Combo Box value

  1. #1
    Forum Contributor
    Join Date
    11-01-2012
    Location
    NJ
    MS-Off Ver
    Excel 365
    Posts
    109

    Run Code based on Combo Box value

    I have a Combo box and I want to run specific vba codes if the combo box text is different things.

    For instance I have 3 funds -

    FUND 1
    FUND 2
    FUND 3

    each fund has its own vba code that needs to run

    FUND 1 CODE
    FUND 2 CODE
    FUND 3 CODE

    Upon hitting the run button on my form - if "FUND 1" is in the combo box, the macro will run "FUND 1 CODE"

    I keep getting errors no matter what I try.

    Any help would be greatly appreciated!

    Thanks

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Run Code based on Combo Box value

    Is it a "form control" or an "active x" control? Is it on a user form or on a worksheet?

    Perhaps attaching a sample workbook showing what you're working with and what you've already tried would be useful.

    BSB

  3. #3
    Forum Contributor
    Join Date
    11-01-2012
    Location
    NJ
    MS-Off Ver
    Excel 365
    Posts
    109

    Re: Run Code based on Combo Box value

    I am sorry, I am not sure what you mean.

    This is an access database so there is a form that opens that has combo box for user to select. The combo box comes from a table.

    Was trying something like:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Run Code based on Combo Box value

    Apologies, I didn't see the Access bit. Brain is in Excel mode today...

    Perhaps this would work for you? You'll need to adjust control names etc.
    Please Login or Register  to view this content.
    BSB

  5. #5
    Forum Contributor
    Join Date
    11-01-2012
    Location
    NJ
    MS-Off Ver
    Excel 365
    Posts
    109

    Re: Run Code based on Combo Box value

    Thank you for your response. I am not sure why, but when I change to "Combo9" which is what my combo box is, nothing happens. No error, but no message box either.

    Any thoughts on that?

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Run Code based on Combo Box value

    Did you change it to Combo9 in both places?
    Please Login or Register  to view this content.
    BSB

  7. #7
    Forum Contributor
    Join Date
    11-01-2012
    Location
    NJ
    MS-Off Ver
    Excel 365
    Posts
    109

    Re: Run Code based on Combo Box value

    Yes I did change to Combo9 in both places

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Run Code based on Combo Box value

    In the properties window for the combobox, under "Event" have you linked the first sub to the Change event?

    BSB

  9. #9
    Forum Contributor
    Join Date
    11-01-2012
    Location
    NJ
    MS-Off Ver
    Excel 365
    Posts
    109

    Re: Run Code based on Combo Box value

    Ahhh! Thank you very much! Works now! Appreciate the help!

  10. #10
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Run Code based on Combo Box value

    Glad I could help

    BSB

+ 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. Replies: 19
    Last Post: 09-06-2014, 06:30 PM
  2. Populate 2nd combo with alpha based on 1st combo with 2 columns of numeric codes
    By dovermac in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2014, 10:09 AM
  3. Using IF code for a combo box to display different cells based on option selected
    By ScottBeatty in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-12-2013, 10:36 AM
  4. Replies: 0
    Last Post: 06-25-2013, 09:42 AM
  5. combo box user form code for two combo boxes
    By robert.begley1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-01-2012, 02:25 PM
  6. [SOLVED] How to reference a second Combo box’s output based on previous Combo Box’s Row source
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2012, 11:27 AM
  7. [SOLVED] Running code based on a change in a linked cell of a combo box
    By cdiaz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2011, 02:34 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