VBA MsgBox

The MsgBox is a dialog box in Excel VBA you can use to inform the users of your program.

Example: A simple message Box

MsgBox “Lets Learn VBA”

 A little more advanced message.

Display Value of Cell A1 using Message Box (First, enter a number into cell A1)

MsgBox “Value is ” & Range(“A1”).Value

 To Display the same, the value of Range A1 into next line

MsgBox “Entered Value is ” & vbNewLine & Range(“A1”).Value

Message Box with Advanced Parameters


MsgBox(prompt[, buttons] [, title] [, helpfile, context])

Prompt: The message text which you want to show.

Buttons: The type of message box like Yes No buttons with Information Icon

Title: The title of the message box window

Helpfile, and Context are the other optional paramerter which we use in very rare


MsgBox “Hi Lets Learn VBA Message Box”, vbYesNo, “User Information”

MsgBox(“Continue Process…”, vbOKOnly + vbExclamation)

VBA MsgBox YesNo

To show the different messages boxes based on the selected option by user.

Sub test()

Dim x As Integer

x = MsgBox(“Continue the Process ?”, vbYesNo)

If x = vbYes Then

MsgBox “Continue….”


MsgBox “Action Aborted…”

End If

End Sub




author image

About admin

You Might Also Like...

Retrieving Data from Mysql/Mariadb
VBA For Excel Hirdesh Bhardwaj
Managing VBA Coding  Errors

Leave a Reply

Your email address will not be published.

Enjoy the tutorial? Please spread the word :)

Follow by Email