+ Reply to Thread
Results 1 to 6 of 6

Stopping point for a macro

  1. #1
    Registered User
    Join Date
    10-13-2008
    Location
    Australia
    MS-Off Ver
    2007
    Posts
    85

    Stopping point for a macro

    Hi,

    I have 2 macro's (macroA, macroB). If I select macroA, it will run the full code.

    If I select macroB, I want it to run macroA up to a certain point. Is this possible?

    Can I also 'skip' part of macroA, so I can continue the macro at a later piont?

    Thanks for your help

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Stopping point for a macro

    You can stop a macro at any point with an Exit Sub statement.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    10-13-2008
    Location
    Australia
    MS-Off Ver
    2007
    Posts
    85

    Re: Stopping point for a macro

    If I run macroB, I want macroA to run up to a certain point. In macro2, this is the code I have:

    Please Login or Register  to view this content.
    But it runs the whole code of macroA. Is there something I can put into macroA to essentially say: if activated by macroB, then run to this point or exit sub at a certain point?

    I appreciate your response

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

    Re: Stopping point for a macro

    You would need to use a private variable to let MacroA know that macrob called it.

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

  5. #5
    Registered User
    Join Date
    10-13-2008
    Location
    Australia
    MS-Off Ver
    2007
    Posts
    85

    Re: Stopping point for a macro

    Hi,

    Thanks for this but i also have some loops in my code of macroA also and each time i run the code, it says that the variable is not defined and selects "Cell" in "For Each Cell In...."

    Does this usually effect a Boolean variable?

    Cheers

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

    Re: Stopping point for a macro

    It's because my code example includes the Option Explicit instruction which requires you to declare all variables in the module.

    Either declare all variables or remove the line.

+ 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