How To Make A VBA Message Box OK Cancel
by admin on Friday, June 15th, 2018 | No Comments
Ever wonder how you can create a vba message box to gather “ok” and “cancel” answers?
This is useful when you want a user to provide confirmation for a delete procedure or other long running process.
When you want to gather feedback from the user do something like this:
Sub VBAMessageBoxOkCancel() Dim intAnswer As Integer 'here is where your answer from the user is held intAnswer = MsgBox("Are you sure?", vbOKCancel, "Please Confirm") Select Case intAnswer Case vbOK MsgBox "Continuing..." Case vbCancel 'exit the procedure Exit Sub End Select End Sub
Here’s a short video:
Let me know if you have any questions.