+ Reply to Thread
Results 1 to 5 of 5

Breaking a Sub with vbOKCancel...

Hybrid View

  1. #1
    Registered User
    Join Date
    10-10-2006
    Posts
    50

    Breaking a Sub with vbOKCancel...

    Here's my MsgBox code:

        MsgBox "Use of this macro assumes you have copied the source data to this worksheet." & _
                vbCrLf & "Please cancel this proceedure and do so now if you have not already done so.", _
                vbOKCancel + vbQuestion, "Before You Proceed!"
    If the user clicks cancel I want to stop the execution of the remaining code. Currently, when cancel is clicked the code executes anyway which ends up producing a bunch of jibberish because it is out of context.

    Is there a way, using the vbOKCancel return value to actually break the Sub?

    ~Len

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Does this link help

    http://www.ozgrid.com/VBA/inputbox.htm

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Surely it's better to just test for the data's existence, or automate the copying.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    10-10-2006
    Posts
    50
    Quote Originally Posted by royUK
    Surely it's better to just test for the data's existence, or automate the copying.

    The copying can't be automated because the source format isn't consistent and the data is too precarious to write testing code. I really Just needed a simple reminder for the user.

    VBAnoob's link was just the thing.


  5. #5
    Registered User
    Join Date
    10-10-2006
    Posts
    50

    Perfect!

    That's awesome, Thanks.


    ~Len

+ 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