+ Reply to Thread
Results 1 to 6 of 6

Run Macro based on input box entry

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Wink Run Macro based on input box entry

    Hello,

    I need code to run a macro based on entry into an input box. For example, the macro name is CC. When you type CC into the input box the macro CC will run. Or if AA is typed, the macro AA will run.

    strMacro = InputBox("Enter the macro name")

    I have the code above to generate the input box but I do not know what else is needed to run the macro based on the input.

    Any help would be greatly appreciated.

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Run Macro based on input box entry

    try
    Please Login or Register  to view this content.
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Registered User
    Join Date
    09-27-2012
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Run Macro based on input box entry

    Hello Thomas,

    Thank you for your reply. Could you please elaborate on how I use this line of code in conjunction with what I already have?

  4. #4
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Run Macro based on input box entry

    All you need to do is add that line of code at the point in your macro where you want to run the macro.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-27-2012
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Run Macro based on input box entry

    Hi,

    I am still having issues getting this to work. Could you do me a huge favor and look at the code in the attached spreadsheet and let me know what I am missing?

    As you can see, I have two macro's (AA and BB). In order for this to work the way I want it to, I should be able to type AA in the input box and the macro AA will run. If I type BB in the input box, macro BB will run.

    The code to accomplish this is in the macro 'Run'. Can you please tell me how I must modify this code in order for it to work properly? If I remove the 'Call StrMacro' code portion, the input box will work, but I know I need that line in there somewhere.

    Any assistance you could provide would be greatly appeciated. I will be needing to create over 100 macros and if I have to go the button route, there will be ALOT of buttons.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Run Macro based on input box entry

    Sorry about that... Here's the modified code:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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