+ Reply to Thread
Results 1 to 9 of 9

Can multiple macros be run with one command button

  1. #1
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Can multiple macros be run with one command button

    I have a command button on a userform that runs a macro called cmdAdd_Click() (see below).
    I want to assign 2 more macros to run behind that one. They are called Macro1 and Macro2.
    Nothing I have tried has worked. A command macro to call all 3..a sub inside the first to call the other 2..ect.
    Any suggestions?



    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Can multiple macros be run with one command button

    Just put this before End Sub of cmdAdd_Click.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Re: Can multiple macros be run with one command button

    Norie,
    I have tried that..it causes a run error..it can't find the file I want to open with Macro1 or Macro2.
    Macro1 and Macro2 work fine if run otherwise...that is what is confusing me.
    Last edited by SLIDE1; 10-10-2012 at 02:58 PM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Can multiple macros be run with one command button

    Where are Macro1 and Macro2 located?

  5. #5
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Re: Can multiple macros be run with one command button

    Quote Originally Posted by Norie View Post
    Where are Macro1 and Macro2 located?

    All macros are located within the same workbook.The cmdAdd macro is activated with the userform...the other two are modules.

  6. #6
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Re: Can multiple macros be run with one command button

    I'll bump this once in hopes that someone can solve it.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Can multiple macros be run with one command button

    So the problem is actually in the code of Macro1 or Macro2?

    Which line of code causes the error?

    Is it this one that appears in both subs?
    Please Login or Register  to view this content.
    If it is what is the value of jobid when you get the error?

    Also, on which sheet should J14 contain the value for jobid?

  8. #8
    Registered User
    Join Date
    09-25-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    62

    Re: Can multiple macros be run with one command button

    Norie,
    Yes the code in Macro1 and Macro2 do not funtion properly when called from within the cmdAdd macro.
    Yes that is the line of code that will not work correctly. However both Macro1 and Macro2 work if run indipendantly..or on their own.
    The value of jobid is correct when the error occurs but the error states that there is no file in that location that matches.
    All files are xls files and like i said both macros are able to find the files if run indipendant of the cmdAdd macro.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Can multiple macros be run with one command button

    Running the subs in from the userform shouldn't make a difference.

    Try this.

    1 Place a breakpoint on Sub Macro1() with F9.

    2 Open the userform.

    3 Click the button to run the code.

    4 When it goes to Debug mode step through Macro1 and Macro2 using F8.

    Also, which worksheet are Range("A22:E27") and Range("L14") on?

    There's no reference for that in the code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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