Sometimes in Excel Macro, you need to execute a Macro / Piece of code as soon as you open the Workbook. By Doing this no need to trigger that Macro or functions just by opening that workbook. There are two methods to achieve this.

Method 1: Auto Run Macro in VBA Module of the Excel:

Follow the below steps:
1.Open Visual Basic Editor (Alt + F11)
2.Add a Module in your VBA Project
3.In that Module Paste your Code inside Sub auto_open


Sub auto_open()
MsgBox ("Welcome " & Application.UserName)
End Sub
Auto Run Macro

Auto Run Macro

Note: In the above example, as soon as you open the Workbook, One message box will open saying “Welcome

Method 2: Auto Run Macro in Workbook:

Follow the below steps:
1.Open Visual Basic Editor (Alt + F11)
2.Double Click on “ThisWorkbook”
3.In Visual Basic Editor paste the below code inside the Open Event of Workbook.


Private Sub Workbook_Open()
MsgBox ("Welcome " & Application.UserName)
End Sub
Auto Run Macro

Auto Run Macro

Note: In the above example, as soon as you open the Workbook, One message box will open saying “Welcome

cover3d_0-89071700_1484285537__1_

Join over 10, 000+ Excel VBA Enthusiasts & get this FREE e-Book Now!