Being able to display message boxes from your Excel application can really make a difference in how users use your application. In Visual Basic for Applications, or VBA, you can use the "MsgBox" function to prompt messages directly from your program. Message boxes are also commonly used in computer programming to report error messages. Displaying friendly error messages can inform users on what steps they can take to fix a particular error.
Launch Microsoft Office Excel, click the "Developer" tab and click "Visual Basic" to open the VBA Editor window.
Press "Alt," "I" and "M" to insert a new code module.
Copy and paste the following code to create a new sub-procedure that displays a message box using VBA code:
Private Sub displayMessageBox()
On Error GoTo Err_displayMessageBox:
MsgBox "Display message box in Excel using VBA", vbInformation, "Test Message"
Click the "Run" menu, then click "Run Sub/UserForm" to run your procedure and display the message box.
- Photo Credit Dynamic Graphics/Dynamic Graphics Group/Getty Images
How to Create an Input Box in Excel VBA
An input box in Visual Basic lets you prompt the user for some input and store the data entered into a variable....
How to Use VBA to Go to the Last Row in an Excel Sheet
Learning how to use Visual Basic for Applications (VBA) in Excel can save you time when searching for data in a worksheet....
How to Run a Windows Application with Excel VBA
In some situations, you may want to open a second Windows application while still operating in another application such as Excel. VBA,...
How to Change the Cell Color in VBA
Developers use the Visual Basic for Applications programming language to create advanced interactions for Office products, such as Excel and Word. You...
How to Use a VBA ComboBox in PowerPoint
Adding a ComboBox control to your PowerPoint presentation can solve the problem of navigating through the slides in your presentation when you...
How to Create a Message Box in Excel VBA
Create a message box based on visual base codes, or VBA's, in Excel by going to tools and then selecting macros. Create...