programming4us
 
Office
 

Microsoft Excel 2010 : Enabling and Examining Macros (part 2) - Examining Macros

4/12/2014 9:06:01 PM

Examining Macros

The best way to get an idea of how macros work is to examine an existing macro. To do that, display the View tab. In the Macros group, click the Macros button, and then click View Macros.

Tip

In the Macro dialog box, you can display the macros available in other workbooks by clicking the Macros In box and selecting a workbook by name or selecting All Open Workbooks to display every macro in any open workbook. If you select either of those choices, the macro names that are displayed include the name of the workbook in which the macro is stored. Clicking This Workbook displays the macros in the active workbook.

The Macro dialog box displays a list of macros in your workbook. To view the code behind a macro, you click the macro’s name and then click Edit to open the Visual Basic Editor.

Tip

Keyboard Shortcut

You can also open and close the Visual Basic Editor by pressing Alt+F11.

Excel macros are recorded by using VBA. Consider, for example, the code for a macro that selects the cell range C4:C9 and changes the cells’ formatting to bold. The first line of the macro identifies the cell range to be selected (in this case, cells C4:C9). After the macro selects the cells, the next line of the macro changes the formatting of the selected cells to bold, which has the same result as clicking a cell and then clicking the Bold button in the Font group on the Home tab.

To see how the macro works, you can open the Macro dialog box, click the name of the macro you want to examine, and then click Step Into. The Visual Basic Editor opens, with a highlight around the instruction that will be executed next.

See Also

To execute an instruction, press F8. The highlight moves to the next instruction, and your worksheet then changes to reflect the action that resulted from executing the preceding instruction.

You can run a macro without stopping after each instruction by opening the Macro dialog box, clicking the macro to run, and then clicking Run. You’ll usually run the macro this way; after all, the point of using macros is to save time.

In this exercise, you’ll examine a macro in the Visual Basic Editor, move through the first part of the macro one step at a time, and then run the entire macro without stopping.

Set Up

Start Excel, open the VolumeHighlights_start workbook, click the Enable Content button on the Message Bar (if necessary), and save the workbook as VolumeHighlights. 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 View Macros.

    Set Up

    The Macro dialog box opens.

    Set Up
  2. Click the HighlightSouthern macro, and then, to display the macro code, click Edit.

    The Visual Basic Editor opens, with the code for the HighlightSouthern macro displayed in the Module1 (Code) window.

  3. In the Visual Basic Editor window, click the Close button.

    Set Up

    The Visual Basic Editor closes, and Excel displays the VolumeHighlights workbook.

  4. In the Macros list, click View Macros.

    The Macro dialog box opens.

  5. Click the HighlightSouthern macro, and then click Step Into.

    The macro appears in the Visual Basic Editor, with the first macro instruction highlighted.

  6. Press the F8 key.

    Excel highlights the next instruction.

  7. Press F8 again.

    The macro selects the Atlantic row in the table.

  8. Press F8 twice.

    The macro changes the Atlantic row’s text color to red.

    Set Up
  9. Click the Visual Basic Editor Close button.

    A warning dialog box opens, indicating that closing the Visual Basic Editor will stop the debugger.

  10. Click OK.

    The Visual Basic Editor closes.

  11. In the Macros list, click View Macros.

    The Macro dialog box opens.

  12. Click the HighlightSouthern macro.

  13. Click Run.

    The Macro dialog box closes, and Excel runs the entire macro.

    Set Up
  14. On the Quick Access Toolbar, click the Save button.

    Set Up

Excel saves your work.

Clean Up

Close the VolumeHighlights workbook.

 
Others
 
- 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
- Microsoft Project 2010 : Strategic Importance of Project 2010
- Microsoft PowerPoint 2010 : Animating a SmartArt Graphic (part 2) - Apply a Customized Animation to a SmartArt Graphic, Reverse the Order of a SmartArt Graphic Animation
- Microsoft PowerPoint 2010 : Animating a SmartArt Graphic (part 1) - Animate a SmartArt Graphic
 
 
REVIEW
 
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- Sigma 24mm f/1.4 DG HSM Art

- Canon EF11-24mm f/4L USM

- Creative Sound Blaster Roar 2

- Alienware 17 - Dell's Alienware laptops

- Smartwatch : Wellograph

- Xiaomi Redmi 2
 
VIDEO TUTORIAL
 
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
 
Top 10
 
- Setup Free Media Server To Stream Videos To DLNA Compatible TV, Xbox 360 & PS3 (Play Station 3)
- How To Install Android Market & Google Apps On Kindle Fire
- How To Make Ubuntu Look Like Windows 7
- How To Add A New Account in MS Outlook 2013
- Get Android & Mac OS X Style Gadgets For Windows 7 & Windows 8 With XWidget
- How To Activate Microsoft Office 2013
- How To Install Actual Facebook App On Kindle Fire
- How To Create, View And Edit Microsoft Office Files On Kindle Fire
- Download Attractive Business PowerPoint Templates For Free At SlideHunter
- How To Use And Enable Hibernate & Sleep Mode In Windows 8