+ Reply to Thread
Results 1 to 3 of 3

Calling Macro Inside Macro

  1. #1
    Registered User
    Join Date
    07-01-2020
    Location
    Yerevan
    MS-Off Ver
    2010
    Posts
    44

    Calling Macro Inside Macro

    Hi All,

    I have Macros calling in a Macro, for example:

    Please Login or Register  to view this content.
    Macro1, Macro2 and Macro4 each import a different text file from a designated folder and perform some operations. However, sometimes the file may not be available (which is ok), but in this case the code stops and there is an error.

    I would like to make an adjustment such that if for example Macro2 does not work (because there is no file to import) it skips it and passes to Macro3 and so on.

    Is this something I can do?

    Many thanks,
    Last edited by AliGW; 07-14-2020 at 02:49 AM. Reason: Code tags corrected.

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Calling Macro Inside Macro

    Untested but wouldn't the on error resume next statement in each of the called macros allow it to return to the main macro to continue execution?
    Happy with my advice? Click on the * reputation button below

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,480

    Re: Calling Macro Inside Macro

    You could convert your subroutines to functions, which would allow you to return the completion status.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    as a function it would be something like this. The important part is how you are currently handling the error. You can incorporate in to that the setting of the completeStatus variable, which is returned to the calling routine.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

+ 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. Manipulating ActiveWorkbook when calling macro from Personal Macro Workbook
    By 146considerations in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-05-2017, 12:16 AM
  2. Error when calling a 'sheet macro' inside a workbook wide macro
    By Rhino_dance in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-09-2016, 03:46 PM
  3. [SOLVED] Define variable in macro than calling that macro inside another macro
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2015, 10:58 AM
  4. [SOLVED] Calling a macro inside another macro
    By MikeMeerkat in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-15-2015, 05:30 AM
  5. Calling macro 10 times, add header list to macro call only once
    By capson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-05-2013, 09:42 AM
  6. [SOLVED] Calling a macro from an event macro. Using nest loops with if statements
    By c0d3crunch3r in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-12-2012, 08:31 AM
  7. Button command doesnt work while calling a macro from a macro
    By bryan444 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2012, 09:39 AM

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