Excel-VBA-Macros Tips and Tricks

Before getting deep into VBA and excel, one need to understand basic structure of Excel sheet.
An excel sheet is generally known as Workbook. A work book has sheets in them. In turn sheets have cells. Every cell is identified or represented by a row and column.
When I started to learn, VBA and Macros in excel, the first question which came to mind was "how to make a macro work as soon as I open a workbook?".
Though basic, still I think it was important. After reading a book on Excel and VBA, I realized it is pretty easy. Follow the steps below
  • Open  a excel file. Lets name it as "Welcome_To_VBA" and save it as Macro Enabled Excel Workbook. This is important for automatic execution of a MACRO
  • Press Alt+F11. This will open VB window.
  • Under VBAProject(Welcome_To_VBA.xlsm), click on ThisWorkbook. A window will open up.


  • Type this particular code in the window 
private sub Workbook_Open()
msgbox("Welcome and Explore amazing world on Excel & VBA")
end sub
  • Ctrl+s will save everything
  • Close the excel workbook as well VB window
  • Now, open the saved workbook i.e. Welcome_To_VBA and a message box will pop up

              With this, it is quite obvious that one can perform operation as soon as a workbooks open. Whatever one writes in between private sub Workbook_Open() and end sub statement gets executed, provided syntax and format is as per as standard guideline. 

Happy VBA...ing :)