+ Reply to Thread
Results 1 to 3 of 3

Check Point in VBA

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162

    Check Point in VBA

    Hi!
    I would like to have a point in my code that displays a message box that asks the user if they wish to continue or exit the macro. A simple "Yes" and "No" button would be ok. This may be a point in the main macro or a point in one of the subroutines.
    1. What would the code look like for stopping the entire macro.
    2. What would the code look like to stop the subroutine only.

    Thanks for any help or advice!!

  2. #2
    Chip Pearson
    Guest

    Re: Check Point in VBA

    Brian,

    The following code will exit the current procedure if the user
    clicks Yes.

    Dim Res As VbMsgBoxResult
    Res = MsgBox("Do you want to continue?", vbYesNo)
    If Res = vbNo Then
    Exit Sub
    End If

    The following code will completely terminate VBA if the user
    clicks Yes. Note that all public (Global) variables will be reset
    to their default values.

    Dim Res As VbMsgBoxResult
    Res = MsgBox("Do you want to continue?", vbYesNo)
    If Res = vbNo Then
    End
    End If


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "Brian Matlack"
    <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Hi!
    > I would like to have a point in my code that displays a message
    > box
    > that asks the user if they wish to continue or exit the macro.
    > A simple
    > "Yes" and "No" button would be ok. This may be a point in the
    > main macro
    > or a point in one of the subroutines.
    > 1. What would the code look like for stopping the entire macro.
    > 2. What would the code look like to stop the subroutine only.
    >
    > Thanks for any help or advice!!
    >
    >
    > --
    > Brian Matlack
    > ------------------------------------------------------------------------
    > Brian Matlack's Profile:
    > http://www.excelforum.com/member.php...fo&userid=3508
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=540310
    >




  3. #3
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162
    Thanks Chip!!

+ 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