BLOGS BY TOPIC
BLOGS BY AUTHOR
BLOGS BY YEAR
The MsgBox command in Visual Basic for Applications allows you to display basic messages, but you can also make it prettier, and even use it to ask questions or display multiple-line messages! Read on to find out more about this versatile VBA command.
- Using MsgBox to Display Messages in VBA Macros (this blog)
- Displaying Message Boxes
- Joining Bits of a Message Together
- Customising your Message Box
- Using MsgBox to Ask Questions
Posted by Andy Brown on 28 September 2011
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Using MsgBox to Display Messages in VBA Macros
Whether you're writing Visual Basic for Applications code in Excel, Access, PowerPoint, Word or any other application, you can use the MsgBox command to display a pop-up message on screen.
Don't confuse message boxes with input boxes, the subject of a separate blog. Message boxes display a message on screen; input boxes ask you to type something in.
Message boxes thus displayed can be simple:
A simple message box, without any customisation at all.
In this message box, we've changed the titles and buttons and added a question mark symbol.
If you want to customise your message boxes more than this, you're out of luck - you can only add so many bells and whistles. In such a case you're best off creating a user form, which you can format as much as you like.
Without further ado, then, let's look at what you can do to create a message box ... beginning with what it is and the basic syntax.