How to Run a Macro Automatically
Last Updated :
23 Jul, 2025
To run a macro automatically when the workbook opens one must enable the developer's tools in Microsoft Excel.
What is a Macro in Excel
Macros allows automating repetitive tasks in Microsoft Excel. Some tasks need to be performed multiple times and repetition of all the actions would consume time. In such type of Scenarios, Macros helps in automating these tasks.
How to Enable the Developer's Tool
Step 1: Go to File > Options > Customize Ribbon
Step 2: Then checkmark the Developer's tool option in the customize ribbon option.

Now you can record Macro, run Macro and do everything that a developer can do.
How to Run Macro Automatically when the workbook opens
Step 1: Go to the developer's menu and then go to the visual basic

Step 2: Go to ThisWorkbook Tab

Step 3: Write down Private Sub Workbook_open() and hit enter. You will then see the below screen.
You can write your code or basically whatever you want between this and it will automatically run every time the workbook is opened.

Let us make a Welcome Message Box:

Step 4: Save the workbook as Excel Macro-Enabled Workbook.
Note: If you don't save it as an Excel macro-enabled workbook then it will not save the macros and it will simply save as a normal excel file.
Output:
Now, whenever you open this workbook you will see this message box pops up automatically.

Macro Might Not Run Automatically If..
Even though you set up a macro to activate upon opening a workbook, it's important to note that this does not guarantee automatic execution. Excel's bui;t-in security measures often default to disabling macros in many workbooks. To ensure successful execution, users must enable the macros explicitly.
Upon opening a workbook with macros, you might encounter a cautionary prompt that requires you to authorize the macro;s execution. This step is crucial for the macro the function properly.
However, Certain individuals might have macros deactivated without receiving any notification, depriving them of the option to activate macros.
These considerations highlights the fact that you cannot assume all users will have macros enable by default. Consequently, it's advised to rely on this method for executing vital macros that are central to critical operations.
Also Read
Macros In Excel With Example
Conclusion
Automating macros to run when a workbook opens is a powerful tool that empowers you to optimize your and enhance productivity. By following these and understanding the security considerations, you can harness the potential of Excel macro to performs tasks effortlessly and ensure consistent and accurate data manipulation. Whether you're dealing with complex calculations, data formatting, or any other repetitive task, running a macro automatically upon opening a workbook can revolutionize your Excel experience.