Excel Macro Basics. IT Training & Development (818) Information Technology.

Similar documents
Macros in Word & Excel

Excel 2007 Introduction to Macros

VBA PROGRAMMING FOR EXCEL FREDRIC B. GLUCK

Excel macros made easy

Working with Macros and VBA in Excel 2007

ACCESS 2007 BASICS. Best Practices in MS Access. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

Microsoft Excel 2013: Macro to apply Custom Margins, Titles, Gridlines, Autofit Width & Add Macro to Quick Access Toolbar & How to Delete a Macro.

Microsoft Excel 2013: Using a Data Entry Form

Microsoft Excel Introduction to Microsoft Excel 2007

Migrating to Excel 2010 from Excel Excel - Microsoft Office 1 of 1

Basic Microsoft Excel 2007

Automate tasks with Visual Basic macros

EXCEL Using Excel for Data Query & Management. Information Technology. MS Office Excel 2007 Users Guide. IT Training & Development

MS WORD 2007 (PC) Macros and Track Changes Please note the latest Macintosh version of MS Word does not have Macros.

Using the Advanced Tier Data Collection Tool. A Troubleshooting Guide

Introduction to Word 2007

NAVIGATION TIPS. Special Tabs

Word 2010: Mail Merge to with Attachments

Introduction to Microsoft Excel 2010

Advanced Excel 10/20/2011 1

To Begin Customize Office

Microsoft Access 2010 Part 1: Introduction to Access

Creating trouble-free numbering in Microsoft Word

EXAMPLE WITH NO NAME EXAMPLE WITH A NAME

Getting Started Guide. Chapter 14 Customizing LibreOffice

Excel 2007: Basics Learning Guide

Skill Set 4. Macros. By the end of this Skill Set you should be able to: Record a Macro Run a Macro Assign a Macro Create a Multiple Action Macro

Symantec Enterprise Vault

Microsoft Migrating to Word 2010 from Word 2003

Creating tables of contents and figures in Word 2013

Excel 2013 Sort: Custom Sorts, Sort Levels, Changing Level & Sorting by Colored Cells

Microsoft Excel Understanding the Basics

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

How To Understand The Basic Concepts Of A Database And Data Science

How To Create A Report In Excel

Adding a File Attachment to a CFS Requisition

WINDOWS 7 EXPLORE INTERNET EXPLORER 8

ECDL. European Computer Driving Licence. Spreadsheet Software BCS ITQ Level 2. Syllabus Version 5.0

Keyboard shortcuts in Excel Keyboard access to the ribbon. In this article WILL MY OLD SHORTCUTS STILL WORK? Hide All

Word 2007: Basics Learning Guide

Microsoft Project 2013

Introduction to Microsoft Access 2003

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

MICROSOFT EXCEL 2011 MANAGE WORKBOOKS

Quick Start Guide. Highly customizable automated trading Automate your trades according to rules and models you create.

3. Add and delete a cover page...7 Add a cover page... 7 Delete a cover page... 7

New Features in Microsoft Office 2007

WHAT S NEW IN MS EXCEL 2013

Microsoft Excel 2010 Part 3: Advanced Excel

Microsoft Access 2007 Advanced Queries

Sample- for evaluation purposes only! Advanced Excel. TeachUcomp, Inc. A Presentation of TeachUcomp Incorporated. Copyright TeachUcomp, Inc.

Microsoft Office 2010

Using Excel for Business Analysis: A Guide to Financial Modelling Fundamentals

MS Word 2007 practical notes

Microsoft Office Excel 2007 Key Features. Office of Enterprise Development and Support Applications Support Group

Internet Explorer 7. Getting Started The Internet Explorer Window. Tabs NEW! Working with the Tab Row. Microsoft QUICK Source

Personalizing your Access Database with a Switchboard

Excel 2007 Basic knowledge

Advanced Excel Charts : Tables : Pivots : Macros

Excel & Visual Basic for Applications (VBA)

Planning and Managing Projects with Microsoft Project Professional 2013

Tutorial 3 Maintaining and Querying a Database

Create a PDF File. Tip. In this lesson, you will learn how to:

Instructions for Creating an Outlook Distribution List from an Excel File

Outlook Mail, Calendar, Contacts, Notes & Tasks. User Guide

Access Tutorial 3 Maintaining and Querying a Database. Microsoft Office 2013 Enhanced

Microsoft Excel 2010 Linking Worksheets and Workbooks

Using Microsoft Office XP Advanced Word Handout INFORMATION TECHNOLOGY SERVICES California State University, Los Angeles Version 1.

Construction Administrators Work Smart with Excel Programming and Functions. OTEC 2014 Session 78 Robert Henry

Microsoft Word 2011: Create a Table of Contents

Highline Excel 2016 Class 26: Macro Recorder

Microsoft Word 2011 Basics for Mac

Advanced Microsoft Excel 2013

WHAT S NEW IN WORD 2010 & HOW TO CUSTOMIZE IT

Tutorial 3. Maintaining and Querying a Database

Microsoft Office 2010

Microsoft Outlook 2003 Quick How-to Guide

Cleaning out Outlook E mail

Microsoft Excel 2013: Headers and Footers

Windows XP Pro: Basics 1

Excel. Microsoft Office s spreadsheet application can be used to track. and analyze numerical data for display on screen or in printed

Microsoft Word 2010 Prepared by Computing Services at the Eastman School of Music July 2010

Advanced Presentation Features and Animation

Basics. a. Click the arrow to the right of the Options button, and then click Bcc.

Microsoft Access 2010 handout

Adding Comments in Microsoft Excel 2003

Instructions to operating forms created in MSWord and Excel

Move between open workbooks. Display the print menu. Select whole spreadsheet. Microsoft Excel Keyboard Keys. General

Microsoft Excel Training - Course Topic Selections

Planning and Managing Projects with Microsoft Project Professional 2013

Outlook Quick Steps & Rules

Creating a Distribution List from an Excel Spreadsheet

How to Use Excel 2007

Outlook 2010 Essentials

Excel basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Excel for Data Cleaning and Management

How To Use Excel 2010 On Windows 7 (Windows 7) On A Pc Or Mac) With A Microsoft Powerbook (Windows Xp) On Your Computer Or Macintosh (Windows) On Windows Xp (Windows 2007) On Microsoft Excel 2010

Microsoft Office Access 2007 which I refer to as Access throughout this book

Scheduling Guide Revised August 30, 2010

Transcription:

Information Technology Excel 2007 User Guide Excel 2007 Macro Basics IT Training & Development (818) 677-1700 training@csun.edu www.csun.edu/it/training

Table of Contents Macro Basics... 1 Introduction... 1 What Are Macros?... 1 What is a Macro?... 1 What Can Macros Do For Me?... 1 Where is My Macro Stored?... 2 Record a Macro... 2 Absolute vs. Relative Reference Macro... 3 Creating and Recording an Absolute Reference Macro... 4 Creating and Recording a Relative Reference Macro... 5 Macro Security... 5 Why is Macro Security Important?... 5 Running Macros... 6 Running Macros... 6 Quick Access to your Macro... 8 Assigning Macros to the Quick Access Toolbar... 8 Delting a Macro...10 Viewing Macro Options...11 Training and Support...12 IT Training...12 Excel 2007 Macro Basics Page i

MACRO BASICS Introduction Find out what a macro can do for you. Save time, energy and keystrokes. Learn how macros can help you perform frequently repeated tasks quickly and easily. This guide will take you through the process of: Understanding what macros are and what they can do for you. Recording macros. Running macros. Deleting macros. Assigning frequently used macros to an icon button. WHAT ARE MACROS? What is a Macro? Macros are bits of code stored in the workbook that can automate repetitive tasks and quickly get your data in order. What Can Macros Do For Me? Macros are used to automate tedious or frequently repeated tasks. How many times in a day do you have to type in a standard page heading for your department or put a standard footer on your document? A macro carries this sequence of actions out quickly. For example, you can create a macro that enters your department name, address, phone number, etc. in one row or cell in your worksheet, centers the date in the cell, and then applies a color and border format to the row or cell. Any task that you find yourself repeatedly performing in Excel, can be done automatically by recording a macro for it. Once recorded, all you have to do is press a combination of two or three keys. That s it! Excel 2007 Macro Basics Page 1

Where is My Macro Stored? When you record a macro, you have the option of storing it in several places: 1. This Workbook 2. Personal Macro Workbook Macros that are stored in This Workbook can only be accessed when that particular workbook containing the macro is open. As long as that workbook is open, the macro you recorded and stored in that workbook is available to you to use in other workbook documents. Macros stored in the Personal Macro Workbook can be accessed from any Excel workbook whenever your Excel application is open. Once you have recorded your initial macro, you can run the macro to perform the task again. The overall process for recording a macro consists of three steps. First, you start the macro recorder and supply a name for the macro. Next, you perform the actions you want to record, such as choosing menu commands, selecting cells, and entering data. Finally, you stop the macro recorder. RECORD A MACRO When you record a macro, the macro recorder records all the steps required to complete the actions that you want your macro to perform. Navigation on the Ribbon is not included in the recorded steps. Note: It is important to plan the macro and test the sequence before you begin recording. Every keystroke or step is recorded, even errors or typo correction. 1. Display the Developer tab. a. Select the Microsoft Office button, and then select Excel Options. b. In the Popular category, under the section Top options for working with Excel, select the Show Developer tab in the Ribbon checkbox. c. Select the OK button. 2. Set the security level to temporarily enable all macros. a. On the Developer tab, in the Code group, select Macro Security (see Figure 1). Figure 1 Macro Security Excel 2007 Macro Basics Page 2

b. Under Macro Settings, select Enable all macros (not recommended as a permanent setting, potentially dangerous code can run), and then select OK. Figure 2 Macro Settings Note: To prevent potentially dangerous code from running, it is recommended that after you finish your work with macros, that you restore your settings to reflect that all macros are disabled. Absolute vs. Relative Reference Macro Before you begin recording a macro, you will need to determine whether the cell references will be absolute or relative. Absolute Reference An Absolute Reference refers to a specific cell address such as A1. For example, when you record your macro using this setting, if you input data in cell D5, Excel will place the data in the D5 position each time the macro is executed. Relative Reference A Relative Reference on the other hand, refers to a cell s position relative to other cells, rather than a specific cell address. For example, if you want the macro to begin in a position relative to the cell in which you click, click on the Use Relative Reference command button on the Developer tab in the Code group. Excel 2007 Macro Basics Page 3

Creating and Recording an Absolute Reference Macro 1. From the Developer tab, in the Code group, select the Record Macro command button. 2. The Record Macro dialog box displays (see Figure 3). Figure 3 Record Macro Dialog Box 3. In the Macro name field, enter a name for the macro. Note: The first character of the macro name must be a letter. Subsequent characters can be letters, numbers, or underscore characters. Spaces cannot be used in a macro name; instead, use an underscore (_) character. 4. To assign a CTRL combination shortcut key to run the macro, in the Shortcut key box, type any lower or uppercase letter that you want to use (see Figure 4). Note: The shortcut key will override any equivalent default Excel shortcut key, while the workbook that contains the macro is open. 5. In the Store macro in list, select the workbook where you want to store the macro, or if you want a macro to be available whenever you use Excel, select Personal Macro Workbook. Excel 2007 Macro Basics Page 4

Figure 4 Record Macro (Shortcut Key, Store Macro In, etc) 6. In the Description box, enter a description for the macro. 7. Select OK to start recording. 8. Perform the action that you need to record. 9. On the Developer tab, in the Code group, select the Stop Recording command button. Creating and Recording a Relative Reference Macro The process for recording a Relative Reference macro is very similar to recording an absolute macro with just one small change. 1. From the Developer tab, in the Code group, select Use Relative References command button. 2. Select the Record Macro command button. 3. Follow steps 2-9 on pages 4-5 (of this document). MACRO SECURITY Why is Macro Security Important? It is a fact that, while most macros are both harmless and helpful, macros are an important security issue. When created with malicious intent, macros can contain destructive code that causes harm to your documents or your system. To protect your system and your files, do not enable macros from unknown sources. In order to have the option to enable or disable macros, but still have access to any macros you want to Excel 2007 Macro Basics Page 5

use, set macro security in your Office programs to medium. This will provide you with the option to enable or disable macros anytime you open a file that contains a macro. Setting Macro Security To set macro security in any Office program that offers VBA macros: 1. From the Developer tab, in the Code group, select Macro Security. 2. The Trust Center dialog box displays (see Figure 1). Figure 1 Trust Center Dialog Box 3. In the Macro Settings section, select your preferred security level. 4. Select the OK button. Note: To prevent potentially dangerous code from running, it is recommended that you do not use the Enable all macros option. RUNNING MACROS Running Macros Since the purpose of creating a macro is to simplify lengthy procedures by automating them, running a macro is quick and easy. Begin the macro by selecting the appropriate active cell. When you open a workbook containing a macro, Excel may display the following dialog box: (See Figure 1). Excel 2007 Macro Basics Page 6

Figure 1 Macro Virus Warning The purpose of this dialog box is to offer protection from a computer virus that may be attached to a macro. It is important that you have confidence in the source of the macro before you enable it. If you want to display the source of the macro before running it, select Display Macros. If you are confident that the Macro does not contain a virus, select Enable Macros. If you believe the macro contains a virus, select Disable Macros or Do Not Open. To Run a Macro 1. Open the workbook that you want to run the macro on. 2. Select the active cell in the worksheet for the macro (if appropriate). 3. Do either: a. Enter the shortcut key combination assigned to the macro when you created it, or b. Select the Developer tab, in the Code group, select the Macros command button. This displays the Macro dialog box for you to select the macro you want to run (see Figure 2). Figure 2 Macro Dialog Box Excel 2007 Macro Basics Page 7

4. Select the macro you want from the Macro name list. 5. If the macro you want does not appear in the Macro name list, select the location in the Macros in list at the bottom of the window. Note: If you cannot locate the macro you want through the macro dialog box, select Cancel, open the workbook containing the macro, and begin again at step 2. 6. Select Run. Excel executes the macro procedures you selected. If the commands that you recorded are not correct, simply delete the macro from the Macro dialog box and record a new one. You can delete the macro by following the steps under Deleting Macros on page 10. QUICK ACCESS TO YOUR MACRO Assigning Macros to the Quick Access Toolbar Excel allows you to add a macro command button to the quick access toolbar for those macros that you access frequently. Once you have created the macro it can be assigned to the quick access toolbar as a command button. 1. Select the Customize Quick Access toolbar arrow (see Figure 1). Figure 1 Quick Access Toolbar 2. Select the More Commands option from the sub-menu. 3. In the Choose Commands from field, select the down arrow to the right of the field (see Figure 2). Figure 2 More Commands Dialog Box Excel 2007 Macro Basics Page 8

4. Select Macros from the Categories list box. 5. Select the appropriate macro from the left, side menu (see Figure 3). Figure 3 Excel Options Dialog Box 6. The macro should now appear in the right, side menu which means that is now on the Quick Access toolbar. 7. Customize the Command button by selecting the macro you want to add from the right, side menu. 8. Select Modify. 9. The Modify Button dialog box displays (see Figure 4). Figure 4 Modify Button Dialog Box 10. Select the symbol that you want to assign it to the macro on the Quick Access toolbar. Excel 2007 Macro Basics Page 9

11. Verify the macro name by selecting the Display Name field (see Figure 4). 12. Select the OK button. 13. Select the OK button on the Excel Options window. 14. The new macro with the button symbol chosen appears in the Quick Access toolbar (see Figure 5). Figure 5 Quick Access Toolbar New Macro Button Added DELTING A MACRO When a macro is no longer needed, you can delete it from the Macros dialog box. Do one of the following: 1. Open the workbook that contains the macro you want to delete. Note: If the macro that you want to delete is stored in the personal macro workbook (Personal.xlsb), and this workbook is hidden, do the following to unhide the workbook: a. In the View tab, in the Window group, select Unhide. b. Under Unhide workbooks, select PERSONAL, and then select OK. 2. Display the Developer tab by doing the following: a. Select the Microsoft Office button and then select Excel Options. b. From the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon checkbox, and then select the OK button. 3. On the Developer tab, in the Code group, select Macros (see Figure 1). Figure 1 Code Group on the Developer Tab Excel 2007 Macro Basics Page 10

4. In the Macros in list, select the workbook that contains the macro you want to delete. For example, select This Workbook. 5. In the Macro name box, select the name of the macro that you want to delete. 6. Select Delete. VIEWING MACRO OPTIONS 1. From the Developer tab, in the Code group on the Ribbon, select the Macros Command button. 2. Excel will display the Macro window (see Figure1, below). Figure 1 Macro Window 3. Select the macro you wish to view. 4. Select the Options button. 5. The Macro Options window displays (see Figure 2). Figure 2 Macro Options Window Excel 2007 Macro Basics Page 11

In the Macro Options dialog box (see Figure 2), you can view your macro s name, short-cut key, and description (if any) that you wrote for this macro. 6. Select OK. TRAINING AND SUPPORT IT Training Contact Us: IT Training & Development Phone: (818) 677-1700 or x1700 (on campus) Email: training@csun.edu Troubleshooting and Support If you experience problems getting started with Office 2007 contact the Help Center at x1400 or helpcenter@csun.edu. Excel 2007 Macro Basics Page 12

NOTES Excel 2007 Macro Basics Page 13

Excel 2007 Macro Basics Page 14

IT s technology training guides are the property of California State University, Northridge. They are intended for non-profit educational use only. Please do not use this material without citing the source excel07_macro_basics_051010 05/10/10