Download Using VBA to Create Pivot Tables
Transcript
12_0789736012_CH11.qxd 232 Chapter 11 6:26 PM Page 232 Using VBA to Create Pivot Tables Enable all macros (not recommended; potentially dangerous code can run)—this setting is equivalent to low macros security in Excel 2003. Because it could allow rogue macros to run in files that are sent to you by others, Microsoft recommends that you do not use this setting. TIP 12/11/06 If you have previously enabled the Developer tab of the Ribbon, you can use the Macro Security icon to jump quickly to the Trust Center dialog box. Visual Basic Editor Macros Dialog Figure 11.1 Enable the Developer tab to access the VBA tools. Macro Recording Tools Shortcut to Trust Center 11 Further, when you save your files, you have to save the files as Excel 2007 macro-enabled workbooks with the .xlsm extension. Enabling the Developer Ribbon Most of the VBA tools are located on a Developer tab of the Excel 2007 Ribbon. By default, this tab is not displayed. To enable it, from the Office icon menu, select Excel Options, Popular. Then choose Show Developer Tab in the Ribbon. As shown in Figure 11.1, the Code group on the Developer tab of the Ribbon offers icons for accessing the Visual Basic Editor, Macros dialog box, macro recording tools, and Macro Security setting. Visual Basic Editor From Excel, press Alt+F11 or choose Developer, Code, Visual Basic to open the Visual Basic Editor, as shown in Figure 11.2. The three main sections of the VBA Editor are described here. If this is your first time using VBA, some of these items may be disabled. Follow the instructions given in the following list to make sure that each is enabled: Project Explorer—This pane displays a hierarchical tree of all open workbooks. Expand the tree to see the worksheets and code modules present in the workbook. If the Project Explorer is not visible, enable it by pressing Ctrl+R.