+ Reply to Thread
Results 1 to 4 of 4

How do I conditionally run a macro based on a selection?

  1. #1
    Forum Contributor
    Join Date
    02-16-2017
    Location
    Bangladesh
    MS-Off Ver
    2021
    Posts
    196

    How do I conditionally run a macro based on a selection?

    I have a sheet called 'Print' in my workbook. There are three modules, and they contain three different 'macros'. Cell 'C8' of this sheet has a drop-down list. This drop-down list has three items named 'One', 'Two', and 'Three'. Cell 'D8' of this sheet has a button called 'Run'. I want to assign a macro to this button, which will execute 'Macro1' if the "Run' button is clicked in cell 'D8' after selecting 'One' in cell 'C8'. After selecting 'Two' in cell C8, clicking the "Run' button in cell 'D8' will execute 'Macro2'.
    Thus, 'macro3' will run for 'three' selections.
    Is it possible to do this without any worksheet event code?
    Can anyone help me with this?
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Ariful Islam; 04-29-2023 at 12:06 PM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How do I conditionally run a macro based on a selection?

    Please Login or Register  to view this content.
    "SelectedMacro" is named range for drop down

    Macros are called "One", "Two", "Three" (!)

    "Run_Macro" is assigned to RUN button
    Attached Files Attached Files
    Last edited by JohnTopley; 04-29-2023 at 02:29 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Contributor
    Join Date
    02-16-2017
    Location
    Bangladesh
    MS-Off Ver
    2021
    Posts
    196

    Re: How do I conditionally run a macro based on a selection?

    Excellent response; it is wonderful.
    You're an incredibly gifted coder. You have a very good grasp of complex material and can respond quite thoughtfully.
    I'm grateful, as always.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: How do I conditionally run a macro based on a selection?

    Certainly not a "gifted" coder but happy that the code gave the result you required: Thanks for rep.

+ 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: 1
    Last Post: 01-04-2017, 06:00 PM
  2. Replies: 1
    Last Post: 01-04-2017, 05:59 PM
  3. Conditionally format entire row based on cell selection
    By Geogee in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-18-2015, 07:04 AM
  4. Need a macro to delete row based on conditionally formatted cell
    By twinklestar922 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2013, 06:47 AM
  5. How do I make a macro conditionally run based on the defined name of a cell
    By JTwrk in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-18-2012, 12:56 AM
  6. How to write one macro that conditionally runs on different columns based on date?
    By ChrisF79 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-13-2011, 12:50 PM
  7. Conditionally formatted date selection
    By CluelessNeedHelp in forum Excel General
    Replies: 6
    Last Post: 09-22-2010, 09:27 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