Hi everyone!
I have the following VBA code:
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.![]()
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
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!
Bookmarks