Excel 2003 VBA Training 

Simple macro to display message in Excel - 

How to Write your first Macro

We have created a simple macro to display message in Excel to understand the basic syntax of a macro.
  • Open a new Excel worksheet
  • Click on Tools and select Macro
  • From the pop-up menu select Visual Basic Editor
  • In the Excel Visual Basic Editor, click on Insert and select Module
  • Start typing 'sub', leave a space and then type an appropriate name like 'message_macro', 'simple-macro', etc and '()' and press enter
  • You will note that the Excel VB editor automatically adds 'end sub' and leaves a gap between the 'sub' and 'end sub'. This is the space where you type your macro code
  • We have typed 'MsgBox("Welcome!")'. This tells Microsoft Excel to pop up a message box with the word 'Welcome!' when you run the macro by clicking on the run arrow or by pressing 'F5' from the keyboard as shown in the Excel training video

Further reading

Introduction to custom macros in Excel

Excel macro tips for beginners

Simple macro to display message