Excel VBA MsgBox

Configurare noua (How To)

Situatie

VBA MsgBox function is like an output function used to display the generalized message provided by the developer. It is like a print statement. This function or statement has no arguments. The personalized messages in this function are written under double quotes, while one must provide the variable reference for the values.

Solutie

Pasi de urmat
Enable Developer Tab

Firstly, if you do not see the Developer tab in your excel, follow the steps below to enable it.

Step 1: Go to FILE > OPTIONS.

vbs msg box

Step 2: Click on Customize Ribbon under Excel Options.

vba msgbox 1

Step 3: On the right-hand side, check the Developer’s box to enable it.

vba msgbox 2

Step 4: Click on “OK” and close this window. Now, you should see the Developer tab in your Excel ribbon.

How to Create a MessageBox using VBA Code?

Step 1: Open Visual Basic Editor

Go to the DEVELOPER tab and click on VISUAL BASIC.

vba msgbox 4

Step 2: Insert Module

Now, click on INSERT and select MODULE. It will insert the new MODULE in your VBA editor.

vba msgbox 6

Step 3: Start Subprocedure

Start your excel macro by typing SUB, the head of the macro. Give a MACRO a name and press the “Enter” key.

Step 4: Start Writing Code for MsgBox

  • In between the Head & Tail of the macro, we need to write the code. So start the word Msgbox. It will display the MsgBox function.

vba msgbox 8

  • As soon as you see the word Msgbox press tab, it will start to show the Msgbox syntax.

vba msgbox 9

  • Now, type the word Welcome to VBA in double-quotes.

vba msgbox 10

Run the Code

Now inside the macro, place a cursor and press the key F5, the shortcut key to run a macro.

Tip solutie

Permanent

Voteaza

(5 din 12 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?