+ Reply to Thread
Results 1 to 4 of 4

Code to end a main sub before end sub point

  1. #1
    Forum Contributor
    Join Date
    06-24-2009
    Location
    SCOTLAND
    MS-Off Ver
    Excel Version 2108
    Posts
    144

    Code to end a main sub before end sub point

    I’m using this code to run consecutive programs, which works really well, apart from one little glitch.

    Please Login or Register  to view this content.
    The problem is that during the Sendmail sub if I select No on the vb, the program continues onto the next sub which unfortunately clears the data I have input to cells on the worksheet (as it should do).

    I therefore need a piece of code which will end the main sub at this point, if No is selected, without running the saveaspdfwithdate2 coding.
    Here is the coding for Sendmail

    Please Login or Register  to view this content.
    Last edited by heliskier89; 07-12-2009 at 02:04 PM.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Code to end a main sub before end sub point

    Use End instead of Exit Sub

    I would also change the structure of the If statement as you have yes/no option

    Please Login or Register  to view this content.
    Last edited by mudraker; 07-11-2009 at 06:36 PM.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Code to end a main sub before end sub point

    On 2nd thought I would replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    06-24-2009
    Location
    SCOTLAND
    MS-Off Ver
    Excel Version 2108
    Posts
    144

    Re: Code to end a main sub before end sub point

    Works great. Thanks alot mudraker.

+ 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