+ Reply to Thread
Results 1 to 10 of 10

Run macro when item from drop-down list is selected

  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    Colorado, USA
    MS-Off Ver
    365
    Posts
    44

    Run macro when item from drop-down list is selected

    I saw a similar posting asking a similar question, but didn't see what I wanted, so thought I'd try asking it this way.

    I have a sheet with a drop-down menu where the user selects a plant from the list, which then populates data in a table for that specific selected plant. I then have the user hit a button to "update" which hides unused rows. I'd like the selection of the item on the drop-down menu to trigger the macro, so they don't have to hit the update button as well. I know it seems pretty simple to select the item then hit the button, but some users won't hit the button and then will wonder why they have extra rows showing up.

    Thanks in advance.
    David

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Run macro when item from drop-down list is selected

    Is the drop down range validation or a combobox?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    08-08-2013
    Location
    Colorado, USA
    MS-Off Ver
    365
    Posts
    44

    Re: Run macro when item from drop-down list is selected

    I used a data validation list. I don't know what a combobox is.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Run macro when item from drop-down list is selected

    What cell is your validation in?

  5. #5
    Registered User
    Join Date
    08-08-2013
    Location
    Colorado, USA
    MS-Off Ver
    365
    Posts
    44

    Re: Run macro when item from drop-down list is selected

    Cell G4 in this particular spreadsheet.

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Run macro when item from drop-down list is selected

    Please Login or Register  to view this content.
    NameOfMacroThatHidesLines needs to be replaced by the name of the macro that is assigned to your button.

  7. #7
    Registered User
    Join Date
    08-08-2013
    Location
    Colorado, USA
    MS-Off Ver
    365
    Posts
    44

    Re: Run macro when item from drop-down list is selected

    So let's say on Sheet 2, I have the user select the plant. I want it to update things on Sheet 3, Sheet 4, and Sheet 5 (tabs). If I understand correctly, I put that macro (Private Sub etc) on Sheet 2, and have it call up the macros that update the other three sheets. On THOSE macros, I need it to go to those sheets then run the macro (right now, the macro doesn't tell it to go to another sheet because the button is on that sheet).

    Assuming the above is correct, can I have multiple Call NameOfMacro lines right after each other for the three sheet updating macros?

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Run macro when item from drop-down list is selected

    Yes. Do any of them need to be finished before you start the others?

    Are all of them Private and in different sheet modules?

  9. #9
    Registered User
    Join Date
    08-08-2013
    Location
    Colorado, USA
    MS-Off Ver
    365
    Posts
    44

    Re: Run macro when item from drop-down list is selected

    They don't need to be done in any particular order.

    <<<Are all of them Private and in different sheet modules? >>>

    Until 10 minutes ago, I didn't know the difference between a Sub and a Private Sub, so the answer is no, not yet. It seems I need to make them all Private Subs, which if I understand correctly, means they will only run on that sheet.

  10. #10
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Run macro when item from drop-down list is selected

    No it means they can only be called from that module. They will run on whatever sheet is defined in the code. If you're going to call them all from the code above then don't make any of them private and you can leave them in the module they're in.

+ 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: 6
    Last Post: 07-18-2013, 07:40 PM
  2. macro to unhide row when a dropdown list item is selected
    By ahng in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2012, 07:17 AM
  3. How to get index of selected item in drop down list?
    By nleahcim in forum Excel General
    Replies: 3
    Last Post: 08-08-2011, 02:08 PM
  4. Replies: 1
    Last Post: 05-18-2010, 07:36 PM
  5. Can I assign a macro to each item in a drop-down list?
    By jbp20717 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-04-2005, 09:05 AM

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