IT tutorials
 
Office
 

Microsoft Excel 2010 : Automating Repetitive Tasks by Using Macros - Running Macros When a Workbook Is Opened

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Product Key Free : Microsoft Office 2019 – Serial Number
4/12/2014 9:15:14 PM

One advantage of writing Excel macros in VBA is that you can have Excel run a macro whenever a workbook is opened. For example, if you use a worksheet for presentations, you can create macros that render the contents of selected cells in bold type, italic, or different typefaces to set the data apart from data in neighboring cells. If you close a workbook without removing that formatting, however, the contents of your workbook will still have that formatting applied when you open it. Although this is not a catastrophe, returning the workbook to its original formatting might take a few seconds to accomplish.

Instead of running a macro manually, or even from a toolbar button or a menu, you can have Excel run a macro whenever a workbook is opened. The trick of making that happen is in the name you give the macro. Whenever Excel finds a macro with the name Auto_Open, it runs the macro when the workbook to which it is attached is opened.

Tip

If you have your macro security set to the Disable With Notification level, clicking the Options button that appears on the Message Bar, selecting the Enable This Content option, and then clicking OK allows the Auto_Open macro to run.

In this exercise, you’ll create and test a macro that runs whenever someone opens the workbook to which it is attached.

Set Up

Open the RunOnOpen_start workbook, click the Enable Content button on the Message Bar (if necessary), and save the workbook as RunOnOpen. Then follow the steps.

  1. On the View tab, in the Macros group, click the Macros arrow and then, in the list that appears, click Record Macro.

    Set Up

    The Record Macro dialog box opens.

  2. In the Macro name box, delete the existing name, and then type Auto_Open.

    Set Up
  3. Click OK.

    The Record Macro dialog box closes.

  4. Select the cell range B3:C11.

  5. On the Home tab, in the Font group, click the Bold button twice.

    Set Up

    The first click of the Bold button formats all the selected cells in bold; the second click removes the bold formatting from all the selected cells.

  6. Click cell C11 and then, in the Macros list, click Stop Recording.

    Excel stops recording your macro.

  7. In the Macros list, click View Macros.

    The Macro dialog box opens.

    Set Up
  8. Click Highlight, and then click Run.

    The contents of cells C4, C6, and C10 appear in bold type.

  9. On the Quick Access Toolbar, click the Save button to save your work.

    Set Up
  10. Click the Close button to close the RunOnOpen workbook.

    Set Up
  11. Click the File tab and then, in the Recent Documents list, click RunOnOpen.xlsm. If a warning appears, click Enable Content, and then click OK to enable macros. RunOnOpen opens, and the contents of cells C4, C6, and C10 change immediately to regular type.

    Set Up
  12. On the Quick Access Toolbar, click the Save button to save your work.

 
Others
 
- Microsoft Excel 2010 : Automating Repetitive Tasks by Using Macros - Running Macros When a Button Is Clicked
- Microsoft Excel 2010 : Automating Repetitive Tasks by Using Macros - Creating and Modifying Macros
- Microsoft Excel 2010 : Enabling and Examining Macros (part 2) - Examining Macros
- Microsoft Excel 2010 : Enabling and Examining Macros (part 1) - Macro Security in Excel 2010
- Microsoft Project 2010 : Maintaining Baselines (part 3) - Resetting a Baseline , Multiple Baselines
- Microsoft Project 2010 : Maintaining Baselines (part 2) - Rolling-Wave Planning with Baselines
- Microsoft Project 2010 : Maintaining Baselines (part 1) - Clearing a Baseline
- Microsoft Project 2010 : Viewing Baselines (part 2) - Formatting the Gantt Chart to Display the Baseline
- Microsoft Project 2010 : Viewing Baselines (part 1) - Tracking Gantt View and the Variance Table
- Microsoft Project 2010 : Understanding and Setting Baselines
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us