+ Reply to Thread
Results 1 to 9 of 9

Getting Sub or Function not defined error for running multiple macros at once

  1. #1
    Registered User
    Join Date
    05-10-2017
    Location
    Denver, Colorado
    MS-Off Ver
    2016
    Posts
    11

    Getting Sub or Function not defined error for running multiple macros at once

    Hi All,

    I have been trying to create a macro to run multiple macros (all from different workbooks), but I keep getting the "Sub or Function is not defined" error. I can't tell if the error is happening on the Sub (macro) or the first Call function.

    I have attached pictures of the error message and what it shows in VBA.

    I appreciate the help!


    Picture of run all macros code.PNG
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by nwood29; 05-10-2017 at 04:05 PM.

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

    Re: Getting Sub or Function not defined error for running multiple macros at once

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED, scroll down and click Manage Attachments.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,057

    Re: Getting Sub or Function not defined error for running multiple macros at once

    Pressing F8 to step through the code line by line instead of just running the code in one shot may help you better identify which exact line is causing the problem.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Registered User
    Join Date
    05-10-2017
    Location
    Denver, Colorado
    MS-Off Ver
    2016
    Posts
    11

    Re: Getting Sub or Function not defined error for running multiple macros at once

    Just tried that and my first Call function (Call CODA_PRODUCT1) is highlighted in blue

  5. #5
    Registered User
    Join Date
    05-10-2017
    Location
    Denver, Colorado
    MS-Off Ver
    2016
    Posts
    11

    Re: Getting Sub or Function not defined error for running multiple macros at once

    Quote Originally Posted by Norie View Post
    Any chance you could upload a sample workbook?

    Click on GO ADVANCED, scroll down and click Manage Attachments.
    Just uploaded the workbook

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

    Re: Getting Sub or Function not defined error for running multiple macros at once

    In the uploaded workbook there are only two subs - Open_All and Run_All.

    Where are the subs CODA_PRODUCT1, Openfile, Key_USA etc located?

  7. #7
    Registered User
    Join Date
    05-10-2017
    Location
    Denver, Colorado
    MS-Off Ver
    2016
    Posts
    11

    Re: Getting Sub or Function not defined error for running multiple macros at once

    Quote Originally Posted by Norie View Post
    In the uploaded workbook there are only two subs - Open_All and Run_All.

    Where are the subs CODA_PRODUCT1, Openfile, Key_USA etc located?
    I am essentially trying to make the macros run with the press of a button, so I assumed that since I opened each workbook containing the macros (e.g. CODA_PRODUCT1, OpenFile, etc.) in the first macro (Open_all), that the Call function would be able to refer to the macros I want to run using the Run_all macro.

    Earlier I tried creating subs for each of the macros I wanted to run (CODA_PRODUCT1, etc.), but I haven't figured out how to do that and combine them all to make them run through one macro.

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

    Re: Getting Sub or Function not defined error for running multiple macros at once

    To run subs in other workbooks you need to use Application.Run and specify both the sub name and the name of the workbook the sub is in.

    Here's a simple example.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-10-2017
    Location
    Denver, Colorado
    MS-Off Ver
    2016
    Posts
    11

    Re: Getting Sub or Function not defined error for running multiple macros at once

    Quote Originally Posted by Norie View Post
    To run subs in other workbooks you need to use Application.Run and specify both the sub name and the name of the workbook the sub is in.

    Here's a simple example.
    Please Login or Register  to view this content.
    This fixed the problem. Thank you!

+ 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. [SOLVED] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  2. Replies: 1
    Last Post: 10-22-2015, 05:50 AM
  3. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  4. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  5. Application Defined or Object Defined Error, Command Button and Vlookup Function
    By stevedomer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-14-2011, 11:20 PM
  6. Excel 2007 : Running XIRR in Excel via a User Defined Function
    By pranavsawjiany in forum Excel General
    Replies: 4
    Last Post: 01-21-2010, 03:58 AM
  7. Problem with running XIRR via a user defined function in Excel 2007
    By pranavsawjiany in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2009, 01:57 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