Results 1 to 2 of 2

Problems with "Exit Sub"

Threaded View

wishny Problems with "Exit... 09-14-2010, 06:54 PM
shg Re: Problems with "Exit... 09-14-2010, 07:15 PM
  1. #1
    Registered User
    Join Date
    09-14-2010
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    3

    Question Problems with "Exit Sub"

    Hi everyone!

    I have the following VBA code:

    Sub UnlockPump()
    MsgBox "This step can not be redone. Are you sure to proceed?", vbQuestion + vbOKCancel
    If Answer = vbCancel Then Exit Sub
    Application.ScreenUpdating = False
    Sheet1.Unprotect
        Range("P33:Q33").Select
        Selection.Locked = False
        Selection.FormulaHidden = False
        Selection.ClearContents
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 10092543
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
    Sheet1.Protect
    Application.ScreenUpdating = True
    End Sub
    I am beginner with VBA. All of the code which starts with a space I have recorded from a macro. The other lines I found on the web and copy paste it.

    The problem about this code is that after the message box pops up, the sub does not end after clicking on cancel. So no matter that you click the macro just goes on.

    Hope that someone can help me here.

    Thanks!
    Last edited by wishny; 09-14-2010 at 07:10 PM. Reason: editing CODE

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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