microsoft excel macros - nee1983 · pdf filespotlight guide microsoft® excel® 2010...

Download Microsoft Excel Macros - Nee1983 · PDF fileSPOTLIGHT GUIDE Microsoft® Excel® 2010 Macros Displaying the Developer Tab To display the Developer tab on the Ribbon: click , then click

If you can't read please download the document

Upload: hoangdien

Post on 06-Feb-2018

235 views

Category:

Documents


4 download

TRANSCRIPT

  • S P O T L I G H T G U I D E

    Microsoft Excel 2010

    Macros

    Displaying the Developer Tab

    To display the Developer tab on the Ribbon: click , then click Options. In the Excel Options dialog box, click Customize Ribbon. Under Main Tabs in the right-side frame, check the Developer box . If desired, click the or button to change where the selected tab will appear on the Ribbon. Click OK.Tip: Certain macro commands also appear under the tab.

    Recording a MacroOnce you begin recording a macro, every command clicked and keystroke made is stored as part of that macro. You may wish to avoid routine, non-specific actions (such as using the keyboard to navigate through cells) while recording.1. Under the tab, click Record Macro in the Code group.2. In the Record Macro dialog box, type a name in the Macro name area and enter details for the

    new macro as needed.

    3. Click OK to close the dialog box. Your mouse cursor changes to reflect recording status.4. Complete the actions you want to include in the recorded macro. When finished, click

    Stop Recording under the tab.

    Using Relative ReferencesBy default, Excel creates macros using absolute references cell references that always point to the same cell. Relative references, on the other hand, will shift depending on where a formula is placed or located.To use relative references: under the tab, click Use Relative References in the Code group. Click again to return to using absolute references.

    In Microsoft Excel 2010, macros are a set of actions performed on a spreadsheet that can be recorded and repeated later for identical effect. You can play back a macro an entire set of actions with one keystroke, automating and speeding up repetitive work processes. Some macro features can be hidden in Excel by default; make sure to display the Developer tab.

    Note: Since some basic knowledge of Excel 2010 is assumed, those in need of a starter guide are referred to the Excel 2010 Quick Reference Guide by Nevada Learning Series.

    www.nlearnseries.com

    Macro commands appear in the Code group.

    Macros can be stored in single workbooks, or made available for use in all your Excel files (Personal Macro Workbook).

    You can add SHIFT to a keyboard

    shortcut.

    Macro SecurityWhile macros can be useful for automating legitimate tasks and procedures, they are also a common vehicle for running

    malicious code on computers. Be wary of opening workbooks received electronically, especially if they are from an unknown or untrustworthy source.

    Enabling Macros in a SpreadsheetWhen a spreadsheet containing macros is opened, you may receive a security warning beneath the Ribbon. If the macros are known to be trustworthy (e.g., the workbook was created by a project team member), click Enable Content to allow them to run.

    Tip: If unsure, you may want to avoid running macros until you are able to take a closer look at them. See Managing Macros, page 2.

    Setting Macro SecurityIf security messages appear too frequently or not often enough, you can change your macro security settings to be more useful.1. Under the tab, click Macro Security in the

    Code group. The Trust Center dialog box opens.Tip: You can also access this screen by clicking , then clicking Options, selecting Trust Center, and finally clicking the Trust Center Settings button.2. Click the radio button beside the Macro Settings option

    most ideal for your situation. For example, if you never intend to use macros in your daily work, Disable all macros with notification should safeguard against accidentally running code. If you use many trusted macros and are constantly contending with security messages, a less protective option may make more sense.

    3. Click OK.

    Click to allow macros. In some situations, this button is replaced by an Options button which can be

    clicked for a menu of possible actions.

  • For information on customization, visit our website at www.nlearnseries.com/customTo order other guides in our series, please contact us by fax (416-487-3121) or by email ([email protected])Microsoft Excel 2010: Macros Spotlight Guide copyright 2012 Nevada Learning Series USA, Inc. We assume no responsibility for errors or omissions in this guide. Excel is a registered trademark of Microsoft.

    ISBN: 978-1-55374-288-3 Printed in the USA

    2Working with Macros

    Adding a Macro to the Quick Access ToolbarClick , then click Options. In the Excel Options dialog box, click Quick Access Toolbar. In the Choose commands from drop-down list, select Macros. Select a macro in the left-side frame and click Add. Click the Modify button below to change the macro name and icon if desired. Click OK.

    Adding a Macro to the RibbonClick , then click Options. In the Excel Options dialog box, click Customize Ribbon. To create a new Ribbon tab and group: Click the New Tab button to create a new Ribbon tab, and the New Group button to create a new group. Click the Rename button to name these elements. If desired, click the or button to change where the selected tab and group will appear on the Ribbon.To add a macro to the Ribbon: in the Choose commands from drop-down list, select Macros. In the left-side frame, select the macro you want to add to the Ribbon. In the right-side frame, select the tab and group the macro will appear in. Click the Add button. Click OK.

    Managing MacrosOpen the Macro dialog box to view and manage active macros.To open the Macro dialog box: under the tab, click Macros in the Code group.

    Running MacrosSelect the macro you want to run, then click the Run button. Alternatively, use the keyboard shortcut you assigned when creating the macro (see Recording a Macro, page 1).

    Deleting MacrosSelect the macro you want to delete, then click the Delete button. Click Yes.

    Changing Macro Description and Keyboard ShortcutSelect the macro you want to change information for, then click the Options button. Make changes as needed in the Macro Options dialog box, then click OK.

    Editing MacrosSelect the macro you want to edit, then click the Edit button. The Visual Basic editor opens to display the macro code (see Getting Help with Visual Basic, below).

    Creating a Macro Without RecordingType a name for the new macro in the Macro name area, then click the Create button. The Visual Basic editor opens (see Getting Help with Visual Basic, below).

    Getting Help with Visual BasicTo take full advantage of macro functionality, Visual Basic knowledge is required. Although writing code is beyond the scope of this guide, the Visual Basic editor contains useful reference material.

    Visual Basic Example: Renaming a MacroFrom the Macro dialog box, select the macro you want to rename and click the Edit button. The Visual Basic editor opens.

    Visual Basic Example: Calling Another MacroIt is possible to nest macros, using one macro to run others as needed. The necessary code will vary depending on where and how the macros are stored.

    For macros appearing in the same worksheet, try:

    call MacroName

    For macros appearing elsewhere, try:

    Application.Run (MacroBook!MacroName)

    Saving a Macro-Enabled WorkbookClick , then click Save As. In the Save As dialog box, click the Save as type drop-down list and choose Excel Macro-Enabled Workbook (*.xlsm). Choose a name and location for the file and click Save.

    At the top-right of the screen, type a question or topic into the

    box and press the ENTER key.

    Use this drop-down list to choose locations to load macros from.

    Change this text which usually appears on the first line to rename the macro. Ensure that you dont delete the syntax brackets following the name! Press CTRL+S to save your changes.

    http://www.nlearnseries.com/custom

    Microsoft Excel 2010 MacrosDisplaying the Developer TabTo display the Developer tab on the Ribbon

    Recording a MacroUsing Relative ReferencesTo use relative references

    Macro SecurityEnabling Macros in a SpreadsheetSetting Macro Security

    Working with MacrosAdding a Macro to the Quick Access ToolbarAdding a Macro to the RibbonTo create a new Ribbon tab and groupTo add a macro to the Ribbon

    Managing MacrosTo open the Macro dialog boxRunning MacrosDeleting MacrosChanging Macro Description and Keyboard ShortcutEditing MacrosCreating a Macro Without Recording

    Getting Help with Visual BasicVisual Basic Example: Renaming a MacroVisual Basic Example: Calling Another MacroSaving a Macro-Enabled Workbook