+ Reply to Thread
Results 1 to 9 of 9

Ending macro early

  1. #1
    Registered User
    Join Date
    11-26-2008
    Location
    New England
    MS-Off Ver
    2007
    Posts
    35

    Ending macro early

    I need to step out of a macro based on a user respone, and I don't know how to end this macro if the user needs to correct a cell entry.

    If they respond "no", I want to sub to end and select the cell where the correction needs to be made.

    Thanks
    Ted

    Please Login or Register  to view this content.
    Last edited by TedH; 01-20-2009 at 11:42 AM.

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Hi Ted. I do not see your problem. By using Exit Sub, you are exiting the macro.

  3. #3
    Registered User
    Join Date
    11-26-2008
    Location
    New England
    MS-Off Ver
    2007
    Posts
    35
    I have a bunch of code after this. If I run it as is, it continues to run the following code....

    I'll paste the code that follows in the original post.
    Ted

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Hi Ted.

    Do you receive the message box "Check the customer name. Correct if needed."? If you do, based on what you have above, the procedure should end after you click OK.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    If you need to know if a sub completes successfully, then change it to a function that returns a Boolean, and test it in the calling sub.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    11-26-2008
    Location
    New England
    MS-Off Ver
    2007
    Posts
    35
    jasoncw: I get the "check customer" msgbox; clicking yes there are no problems. On clicking "no", the end sub isn't doing it's thing; the macro continues to run because I'm getting a runtime error on the saveas function a little further down.

    shg: I'm still a noob; I usually throw a dummy expression into the worksheet to see if the code works. {i.e. "serenity now!"}

  7. #7
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Can you post the code where variable ResponseClose is assigned?

  8. #8
    Registered User
    Join Date
    11-26-2008
    Location
    New England
    MS-Off Ver
    2007
    Posts
    35
    jasoncw:

    <<hand smacking against forehead>>

    That was the problem, I copied the msgbox code from below and didn't update all the variables.

  9. #9
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Glad you figured it out.

+ 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