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.
Find Error Line Number in VBA With Erl
In this post you are going to find out a way of handling errors in your code with the Erl function. Erl displays the last label before the error Another alternative error handling solution is using labels at each point in long procedure. Here we get a random error: Here is the code behind the […]
Here Is A Customized Msgbox VBA Example
Here is an example of a customized VBA Msgbox. We giving some richtext and customizable flair to the rather ordinary message box. The following code provided with the code after the screenshot, is going to provide you with the ability to really make the ordinary message box shine! Sub MsgboxVBAExamples() Dialog.Box “VBAHowTo.com is your source […]
How To Use A Variable In A VBA Message Box.
In this post I’m going to show you how to use a variable in a vba message box. This is used commonly to notify the user that an entered item in a combo box is not in the list, also per this post it’s to display the error number or the error description to the […]
How To Make A VBA Msgbox Yes No
You can use a VBA Msgbox Yes No to get guidance from the user an the control your program’s flow In the following example I am asking the user to confirm whether or not they want to continue. I am storing the answer in the integer variable intAnswer, and then my algorithm processes their answer […]