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
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
Note: In the above example, as soon as you open the Workbook, One message box will open saying “Welcome
I want to study this book.Please send me,becouse I can’t download it.
After subscribing using your email ID, you would receive an email with a link to download this e-Book.
Let me know if you were able to download this ebook.