+ Reply to Thread
Results 1 to 7 of 7

how to jump in a Sub to another location ?

  1. #1
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    how to jump within a Sub

    I have several routines in my Sub that all use an "if not". In the case of "if not" being true each routine does the same (see example). This makes the program length very long. Therefore I thought it would be nice if I could jump instead to the last "do various things" before End Sub. That way I could remove the "do various things" from each routine which would significantly shorten the Sub. How do I do that?

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: how to jump within a Sub

    Hi,

    Have you tried the GoTo instruction:
    GoTo Line1:
    HTH

  3. #3
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: how to jump within a Sub

    Like this? If like this how do I find out the Line number? I don't have any Line numbers in my VB editor.

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    how to jump in a Sub to another location ?

    What I want to do is illustrated in the example below. How does the actual script look like?

    Please Login or Register  to view this content.
    Last edited by dschmitt; 02-26-2010 at 04:25 AM.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: how to jump in a Sub to another location ?

    Perhaps....

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: how to jump in a Sub to another location ?

    yes, this is working. Thank you.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: how to jump in a Sub to another location ?

    Going forward - do not post duplicate threads.

+ 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