Friday, December 11, 2009

How do I create a message box vba macro in Excel?

This is a fairly easy macro to write and is good practice for beginners. Now we will make a message box automatically pop up when opening your workbook. You can either use the Auto Open method or the Workbook Open method. These macros will display the message "Hello" when you open the workbook.

Sub Auto_Open()
Msgbox "Hello"
End Sub

This code would be located in the module. However, if you use the second method, the code must be in the workbook (double click "This Workbook" in the explorer window). Click on the drop down list (that says General) and select Workbook. Click on the drop down list (that says declarations) and select Open.

Private Sub Workbook_Open()
Msgbox "Hello"
End Sub

You've just created your first macro. I will try to integrate different levels of difficulty from beginner, intermediate, and advanced tips for macros, formulas, and Excel tips in general.

No comments:

Post a Comment

I'd love to hear from you!
-Nick