Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Excel Tutorial
  • Excel Formulas
  • Excel Shortcut Keys
  • Data Analysis in Excel
  • Formatting in Excel
  • Excel Workbooks
  • Statistical Functions
  • Data Visualization in Excel
  • Pivot Tables in Excel
  • MS Excel Quiz
  • Excel Interview Questions
  • Advance Excel
Open In App
Next Article:
How to Run a Macro Automatically
Next article icon

How to Run a Macro Automatically

Last Updated : 13 Dec, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

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.

Enable-Developer's tool

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

Run-Macro-Automatically

Step 2: Go to ThisWorkbook Tab

Workbook-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.

ThisWorkbook(Code)

Let us make a Welcome Message Box:

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.

Welcome to this workbook

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.


Next Article
How to Run a Macro Automatically

J

jimishravat2802
Improve
Article Tags :
  • Excel

Similar Reads

    How to make a Python auto clicker?
    Auto-clickers are tools that simulate mouse clicks automatically at a given location and interval. Whether you're automating repetitive tasks in games, productivity applications, or testing graphical user interfaces (GUIs), creating an auto-clicker in Python is both a fun and practical project. In t
    4 min read
    How to Record a Macro in Excel
    Excel Macro is simply a record button that records a set of actions performed on Excel that can be run multiple times. For example, if you have to format some raw data on a weekly basis you can use a macro to record yourself formatting the data once and let Excel automate the task in the future. it'
    11 min read
    How to Enable & Run a Macro in Excel? 6 Ways
    We can record a macro in Excel or write from scratch in VB Editor. Excel provides different options to run a macro. In this article, we explore four different approaches to running a macro in an Excel application. Even while executing an Excel macro is a straightforward process for seasoned users, i
    5 min read
    How to Automate Repetitive Tasks on Mac?
    Looking for ways to automate repetitive tasks on Mac? Automating your workflow on macOS can save time and boost productivity by handling routine tasks like file management, app launching, and system maintenance. With tools like AppleScript, the Automator app on Mac, and Mac shortcuts, there are many
    4 min read
    How to Automatically Insert Date and Timestamp in Excel?
    The Date and Timestamp is a type of data type that determines the date and time of a particular region. It contains some characters along with some encoded data. This format may vary from language to language. Keeping track of date and time helps in managing records of our work as well as segregate
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences