Welcome to Excel Avon
What is Message Box in Excel
Message Box is one of the most frequently used Functions in VBA Macro. VBA (MsgBox) is an inbuilt dialog box window that displays or displays a message alert box containing an optional set of buttons, icons and other logic settings Message box title: This is commonly used to display what VBA What is the message box about. In this article, we are going to show you how to create custom message boxes in Microsoft Excel using VBA.
How to Create Message Box in Excel
Like functions and formulas in Excel, there is also the MSGBOX function. So let’s see how to make a message box. In this example, we want to create a dialog box just to say “this is simple message hello world”.
First we have to click on Visual Basic in Developer tab. You can also press Alt + F11.
You should now have the VB editor open. In Project Explorer, you will find your workbook file listed. Now go to the Insert tab and insert the module.
This will create a new blank module.
In the code window, we will type “Text_Messagebox()”. And you press Enter then Excel adds the “End Sub” line below this line. Now whatever code we will write it should be between these two lines.
Now let us add a comment which will make it easy to understand why we are typing the code here.
We type our MsgBox function.
Now we will click the Run button or you can also run the macro by pressing F5.
After clicking run button we will see our message box.
Note that now we add OK cancel button in this message box while “OK” is the default button. Let’s go to VB Editor
Now we will click the Run button or you can also run the macro by pressing F5. Code Run button as we mentioned below.
After clicking run button we will see our message box.
Selecting a different button in msgbox
Click Cancel Button for close the msgbox window, now let’s see by adding Yes, No button.
Now we will click the Run button or you can also run the macro by pressing F5.
After clicking run button we will see our message box.
We will close the pop-up window of this message box and then see the icon with the button and will also add the question icon along with the Yes, No button in the pop-up window
Again, we will click the Run button or F5.
After clicking run button. You can see that the question icon has been added in the pop-up window.
We will remove the question icon and then we will add the information icon.
Again, we will click the Run button or F5. After clicking run button. You can see that the Information icon has been added in the pop-up window.
Now we will add the message box title.
Again, we’ll click the Run button or F5. After clicking on the Run button. You may notice that the information title, icon, and yes, no button has been added to the pop-up window.
So, I hope you have understood How to Use Message Box in Excel VBA Macros and for more information, you can follow us on Twitter, Instagram, LinkedIn, and YouTube as well.
You can also see well-explained video here