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
- Displaying Message Boxes
- Joining Bits of a Message Together
- Customising your Message Box (this blog)
- Using MsgBox to Ask Questions
This blog is part of our Excel macros online tutorial series. Our main business is running training courses in Excel, courses in VBA and training in many other Microsoft applications.
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.
Customising your Message Box
You can add a few bells and whistles to a message box - but only a few.
Different Symbols
You can display 4 different symbols:
Key word | Symbol |
---|---|
vbCritical |
![]() |
vbQuestion |
![]() |
vbExclamation |
![]() |
vbInformation |
![]() |
So, for example, this would display a message box with an exclamation mark symbol and an OK button (bizarrely, you add your choices together):
'display a message with an exclamation mark symbol
MsgBox "Cats like plain crisps", vbExclamation + vbOKOnly
Different Buttons
In addition to the symbols above, you can control which buttons you see as follows:
Key word | Buttons that you get |
---|---|
vbOkCancel | OK and Cancel |
vbOkOnly | OK only |
vbYesNo | Yes and No |
vbAbortRetryIgnore | Abort Retry and Ignore |
vbRetryCancel | Retry and Cancel |
vbYesNoCancel | Yes No and Cancel |
To understand why you would display different combinations of buttons, see the last entry in this blog about asking questions with message boxes.
- Using MsgBox to Display Messages in VBA Macros
- Displaying Message Boxes
- Joining Bits of a Message Together
- Customising your Message Box (this blog)
- Using MsgBox to Ask Questions