Return to VBA Code Examples

VBA – Dialog Box

This article will demonstrate how to use Dialog Boxes in VBA.

Dialog Boxes are used to return information to the user.  The most common dialog box that is used is the Message Box, but we can also use the Input Box.

Message Box


The syntax of the Message Box is as follows:




Message returned to the user – required


Visual Basic buttons – defaults to OK if omitted


Title of Message box – optional


Helpfile – optional

Context – optional

Simple Message Box

A simple message box just requires the prompt – the message you are returning to your user.  The OK button will automatically be displayed.


YesNo Message Box

Adding in buttons can make you message box more flexible.

We can select the type of box from a drop down list of VB constants.

MsgBox Constants


As well as the Yes/No button, we can icons to display in our message box to indicate to the user what type of message is being displayed.

MsgBox Question

NOTE: if you do not select a button constant, but do select an information constant, you need to omit the brackets from around the message box arguments.

MsgBox Info

Adding a Title

We can also fill in the title argument.

MsgBox Title

For a more detailed article about Message Boxes, click here.

Input Box

An input box is a Dialog Box that asks the user a question, and returns a result.

MsgBox InputBox

For a more detailed article about Input Boxes, click here.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as

Learn More!