Message Box

1. First open your microsoft excel program

2. Make sure the developer option is enabled. Please see the link

3. And of course you have to allow or enable the settings for macro to run the code
(File –> Option –> Trust Center –>Trust Center Settings –> Macro Settings –> Check “Enable all macros”)

4. After that, navigate your mouse unto developer tab. You can see there is an Insert drop down button (which is form controls).

5. Click insert, Under the Active x control, click command button. Place it in the current sheet. From there, you can draw a command button.

6. So you now have a command button, this will not finish our task, we have to input the code inside the command button (active x control) for it to run. [ninja mode. lol]

7. Double click the command button and then type this code below inside the private sub command:

        MsgBox “Hello Beautiful World”

Creating a message Box in MS excel using VBA
Hello Beautiful World

 or like this:

Private Sub CommandButton1_Click()
MsgBox “Hello Beautiful World”
End Sub

8. Now run it, press F5
       cchhhaarraaaann! wooollaa(viola)

Now you had created a message box, but what if ……you want to pop up this message box at the time the workbook is activated.

1. First ,you noticed in the design mode we actually wrote the code in the current sheet i.e., “sheet1”
      (if you cannot see the sheet1, just go to the design mode or click view code in developer tab then click the view tab, click project explorer)

2. For we to accomplish our goal, that code must be on the workbook (as you can see in your left hand, Project explorer > Microsoft excel objects > ThisWorkbook)

3. Double click on ThisWorkbook then copy paste this:

Private Sub Workbook_open()
MsgBox “Hello Beautiful World”
End Sub

4. Close the file and save but before you save, the file type must be “Excel Macro-Enabled Workbook”

5. Open your test excel  VBA file. See if it works

Next topic is, How can you create a message box without using any 3rd party application?
—-The Visual Basic Script

Don’t forget to subscribe or follow me on google + for more future posts

Hit this post a PLUS! 🙂

1 comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: