My First Macro

Simple macro to display message in Excel РHow to Write my 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 Macros (VBA) tips for beginners

One thought on “My First Macro

  1. Sir,
    mai yeh chahta hu ke mai koi bhi entry user from mai karo to woh automatic party ke ledger mai transfer ho jaye jese ke mai cashbook mai userfrom ki madad se entry karo to woh cash book mai to ho jaye lekin wohi entry party ke account mai bhi enter ho jaye

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.