+ Reply to Thread
Results 1 to 2 of 2

Make Called Macro End the First Macro

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Make Called Macro End the First Macro

    Sub FirstMacro()
    
    Code to do this or that
    
    Call SecondMacro
    
    Code to do this or that
    
    End Sub
    Sub SecondMacro()
    
    IF  this is true GoTo ErrorMsg
    	Then     'okay to back to First Macro
    	Exit Sub
    
    ErrorMsg:
    MsgBox "Sorry, the macro is finished."     
    ‘at this point do not return to First Macro
    
    End Sub
    When I call a Second Macro within the First Macro
    and the Second Macro ENDS with the ErrorMsg,
    I don’t want to resume the FirstMacro.
    How can I stop it from returning to complete the First Macro?

    TIA
    you guys are awesome, I have learned so much here
    more than all my books combined

  2. #2
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500
    why not try pass a value between the two.


    sub test1()

    dim macroerror as string

    macroerror =""

    macroerror = SecondMacro (macroerror)

    if macroerror <> "" then exit sub
    end sub
    Sub SecondMacro(macroerror as string)

    IF this is true GoTo ErrorMsg
    Then 'okay to back to First Macro
    Exit Sub

    ErrorMsg:
    macroerror = "Yes"
    MsgBox "Sorry, the macro is finished."
    ‘at this point do not return to First Macro

    End Sub
    Last edited by funkymonkUK; 03-07-2007 at 11:52 AM.
    I am currently looking for new employment. If you like my work please get in touch. (Preferably Permanent position with ?25k p.a but willing to work on small projects for extra cash)

+ 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