Excel Macros For Dummies. Dick Kusleika
Чтение книги онлайн.

Читать онлайн книгу Excel Macros For Dummies - Dick Kusleika страница 13

Название: Excel Macros For Dummies

Автор: Dick Kusleika

Издательство: John Wiley & Sons Limited

Жанр: Программы

Серия:

isbn: 9781119844457

isbn:

СКАЧАТЬ button, in that you assign a macro to run when the control is selected.

      Placing a macro on the Quick Access Toolbar

      You can also assign a macro to a button on the Quick Access Toolbar. The Quick Access Toolbar sits either above or below the Ribbon. You can add a custom button that runs your macro by following these steps:

      1 Right-click your Quick Access Toolbar and select Customize Quick Access Toolbar.This opens the dialog box shown in Figure 1-9.

      2 Select Macros from the Choose Commands From drop-down list on the left.

      3 Select the macro you want to add and click the Add button.

      4 (Optional) Click the Modify button to change the icon or display name, and then click OK to close the Modify Button dialog box.

      5 Click OK to close the Excel Options dialog box.

Snapshot of Adding a macro to the Quick Access Toolbar.

      Covering the fundamentals of building and using macros is one thing. Coming up with good ways to incorporate them into your reporting processes is another. Take a moment to review a few examples of how macros automate simple reporting tasks.

      

Open Chapter 1 Samples.xlsm to follow along in the next section.

      Building navigation buttons

      Creating a macro to navigate to a sheet is quite simple.

      1 Start at the sheet that will become your switchboard or starting point.

      2 Start recording a macro.

      3 While recording, click the destination sheet (the sheet this macro will navigate to).

      4 After you click in the destination sheet, stop recording the macro.

      5 Assign the macro to a button.

Snapshot of Use macros to build buttons that help users navigate the reports.

      FIGURE 1-10: Use macros to build buttons that help users navigate your reports.

It’s useful to know that Excel has a built-in hyperlink feature, allowing you to convert the contents of a cell into a hyperlink that links to another location. That location can be a separate Excel workbook, a website, or even another tab in the current workbook. Although using a hyperlink may be easier than setting up a macro, you can’t apply a hyperlink to form controls (such as buttons). Instead of a button, you’d use text to let users know where they’ll go when they click the link.

      Dynamically rearranging PivotTable data

Snapshot shows this report allows users to choose their perspective.

      FIGURE 1-11: This report allows users to choose their perspective.

Snapshot of the macros behind these buttons rearrange the data fields in a PivotTable.

      FIGURE 1-12: The macros behind these buttons rearrange the data fields in a PivotTable.

      1 Create your PivotTable and PivotChart.

      2 Start recording a macro.

      3 While recording, move a pivot field from one area of the PivotTable to the other. When you’re done, stop recording the macro.

      4 Record another macro to move the data field back to its original position.

      5 After both macros are set up, assign each one to a separate button.

      You can run your new macros in turn to see your pivot field dynamically move back and forth.

      Offering one-touch reporting options

      The last two examples demonstrate that you can record any action that you find of value. That is, if you think users would appreciate a certain feature being automated for them, why not record a macro to do so?

Snapshot of Offering prerecorded views not only saves time and effort, but it also allows users that don’t know how to use advanced features to benefit from them.

      FIGURE 1-13: Offering prerecorded views not only saves time and effort, but it also allows users that don’t know how to use advanced features to benefit from them.

Snapshot of giving the audience a choice 
              <a href=СКАЧАТЬ