+ Reply to Thread
Results 1 to 5 of 5

If.....Then GoTo.......

  1. #1
    Registered User
    Join Date
    02-01-2006
    Posts
    44

    If.....Then GoTo.......

    Hi,

    Stuck again..

    I have a line of code that reads

    If (P20) < 1 Then GoTo ????

    I want the ???? to refer to the last line of the Sub which is..

    Sheets("Customer List").Select

    In other words to miss out all other lines of the code and go directly to the last line. I keep getting told to either refer to a line label or a line number, currently the code does not have line numbers (I think) and I dont know how to create a "label" that refers to a line within the code.....


    Help.

  2. #2
    Registered User
    Join Date
    02-15-2006
    Location
    Utrecht, Holland
    Posts
    5

    answer

    replace the ??? with anyname followed by ":" so for example Exitthis:

    code
    -
    -
    Exitthis:
    Sheets("Customer List").Select
    End Sub

  3. #3
    Ken Johnson
    Guest

    Re: If.....Then GoTo.......

    Hi Alec,
    Write a label after the GoTo and then before Sheets("Customer
    List").Select
    For example:

    If (P20) < 1 Then GoTo SKIP

    rest of code...

    SKIP:Sheets("Customer List").Select
    End Sub

    Note the : after the label SKIP
    The SKIP label does not affect the normal execution of the last line
    when (P20)>=1
    Ken Johnson


  4. #4
    R..VENKATARAMAN
    Guest

    Re: If.....Then GoTo.......

    just before the line
    Sheets("Customer List").Select
    type
    line1:
    (i.e line1 and colon)
    the original line should be
    if range("P20")<1 goto line1



    "Alec H" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi,
    >
    > Stuck again..
    >
    > I have a line of code that reads
    >
    > If (P20) < 1 Then GoTo ????
    >
    > I want the ???? to refer to the last line of the Sub which is..
    >
    > Sheets("Customer List").Select
    >
    > In other words to miss out all other lines of the code and go directly
    > to the last line. I keep getting told to either refer to a line label
    > or a line number, currently the code does not have line numbers (I
    > think) and I dont know how to create a "label" that refers to a line
    > within the code.....
    >
    >
    > Help.
    >
    >
    > --
    > Alec H
    > ------------------------------------------------------------------------
    > Alec H's Profile:
    > http://www.excelforum.com/member.php...o&userid=31042
    > View this thread: http://www.excelforum.com/showthread...hreadid=512643
    >




  5. #5
    Registered User
    Join Date
    02-01-2006
    Posts
    44

    Solved

    Thanks all

+ 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