+ Reply to Thread
Results 1 to 9 of 9

Function and Goto Labels

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Function and Goto Labels

    Hi,

    Instead of having all the code in my sub, I decided to add function to divise the sub out.
    However, in my sub, I have a Label statement Goto EXIT_DOOR which I declare just above the End Sub with some setting such as:
    EXIT_DOOR:
    Set ws = nothing
    Set dmProject = nothing
    End Sub

    Now, how can in my function to do as if Error, go back to the sub but go to EXIT_DOOR of the sub?

    Thanks

  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: Function and Goto Labels

    Unfortunately you can't jump to a label in another sub/function.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Function and Goto Labels

    Any recommendation on how to do it via other way?

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,335

    Re: Function and Goto Labels

    @Norie
    I think you mean "fortunately"!

    Use an error handler in the calling Sub.
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Function and Goto Labels

    Can you give a example?

  6. #6
    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: Function and Goto Labels

    Please Login or Register  to view this content.
    Last edited by shg; 07-01-2015 at 01:16 PM.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Function and Goto Labels

    I forgot. This function does call the error, but what if it's not related to error but more like: If a string is found?

  8. #8
    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: Function and Goto Labels

    See Help for the Err.Raise method.

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,665

    Re: Function and Goto Labels

    Please Login or Register  to view this content.
    Last edited by protonLeah; 07-01-2015 at 07:44 PM.
    Ben Van Johnson

+ 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] GoTo page function
    By Grumpee in forum Excel General
    Replies: 3
    Last Post: 02-11-2013, 03:51 AM
  2. goto function
    By jbrandon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2010, 12:32 PM
  3. GOTO Function...
    By Prax in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2007, 12:16 PM
  4. Goto statement in an IF function
    By =\ in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  5. [SOLVED] goto function
    By Ray in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 08-07-2005, 07:05 PM

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