Exploring Microsoft Excel

Slides:



Advertisements
Similar presentations
Visual Basic for Applications. What it does Extends the features and built in functions of Excel – Create and run VB procedures – Some may be easy to.
Advertisements

Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Exploring Microsoft Excel 2002 Chapter 9 Chapter 9 A Professional Application: VBA and Date Functions By Robert T. Grauer Maryann Barber Exploring Microsoft.
Using Macros and Visual Basic for Applications (VBA) with Excel
Tutorial 7: Developing an Excel Application
Developing an Excel Application
Tutorial 8: Developing an Excel Application
XP New Perspectives on Microsoft Excel 2003, Second Edition- Tutorial 8 1 Microsoft Office Excel 2003 Tutorial 8 – Developing an Excel Application.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
With Microsoft Excel 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Excel 2010.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA By Robert T. Grauer Maryann Barber.
Microsoft Excel 2003 Illustrated Complete with Excel Programming.
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Using the Visual Basic Editor Visual Basic for Applications 1.
Adding Automated Functionality to Office Applications.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Excel Lesson 14 Creating and Using Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Macros and VBA A macro is a set of instructions that tells Excel which commands to execute.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Introduction to VBA. This is not Introduction to Excel We’re going to assume you have a basic level of familiarity with Excel If you don’t, or you need.
Macros n Macros are little programs that you can create to automate particular tasks that you may want to execute more easily than having to specify all.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
Microsoft Excel 2007 © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
EXCEL 2007 MACROS.  TOM FARRAR OF CNEXTWAVE INC.  GOAL : LEARNING ABOUT EXCEL MACROS.  PRESENTATION INCLUDES DISCUSSION AND DEMONSTRATION.  QUESTIONS.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
Microsoft Excel Macros & Excel Solver (IENG490)
Introduction to VBA MGMI Aug What is VBA? VBA = Visual Basic for Application Excel’s powerful built-in programming language An event-driven.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Excel 2010 by Robert Grauer, Keith.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Exploring Microsoft Office XP - Microsoft Word 2002 Chapter 71 Exploring Microsoft Word Chapter 7 The Expert User: Workgroups, Forms, Master Documents,
Visual Basic for Applications Macro Programming For Microsoft Office.
VBA Lab 2 I ns.Samia Al-blwi. Visual Basic Grammar Object: Visual Basic is an object-oriented language. This means that all the items in Excel are thought.
OCC Network Drives  H:\  P:\ 
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA.
Chapter 9 Macros And Visual Basic For Applications.
Chapter 11: Introduction to VBA Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Introduction to Excel VBA UNC Charlotte CPE/PDH Series December 17, 2009.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Introduction to Microsoft Excel Macros COE 201- Computer Proficiency.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
1 CA202 Spreadsheet Application Automating Repetitive Tasks with Macros Lecture # 12 Dammam Community College.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
The Advantage Series ©2005 The McGraw-Hill Companies, Inc. All rights reserved Chapter 12 Introducing Visual Basic for Applications Microsoft Office Excel.
Exploring Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 1 – Introduction to Excel: What is a Spreadsheet?
Excel Tutorial 8 Developing an Excel Application
Visual Basic.NET Windows Programming
Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and
Exploring Excel Chapter 1
Microsoft Access Illustrated
Microsoft Office Illustrated
Microsoft Excel 2003 Illustrated Complete
Learning Excel Session 9 and 10 Dr. Chaitali Basu Mukherji.
Introducing VBA Macros
Macro.
Lesson 1 - Automating Tasks
Microsoft Office Excel 2003
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Microsoft Excel 2007 – Level 2
Visual Basic for Applications: Introduction
Presentation transcript:

Exploring Microsoft Excel Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Objectives (1 of 2) Define a macro Record and run a macro; view and edit a simple macro Use the InputBox and MsgBox statements Use a keyboard shortcut or customized toolbar to execute a macro Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Objectives (2 of 2) Describe the function of the Personal Macro workbook Use the Step Into command to execute a macro one statement at a time Use Copy and Paste to duplicate an existing macro Use Visual Basic IF and DO statements to make decisions Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Overview Use macros to automate repetitious tasks Macro is a set of instructions for Excel Macro instructions are written in the Visual Basic for Applications (VBA) programming language Use the macro recorder to create macros Create more powerful macros Exploring Microsoft Excel 2002 Chapter 8

Introduction to Macros Macro recorder stores Excel commands Commands are written in Visual Basic for Applications Macros can be displayed with Visual Basic Editor (VBE) Use VBE to create, edit, run, and debug (fix) Excel macros Use Project Explorer in left-hand pane to locate macro modules Statements appear in Code window Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Macro Statements Sub statement, followed by the name of the macro Sub is short for subroutine Comments begin with apostrophe (’) Comments provide useful information about the purpose of the macro With and End With statements Perform multiple actions on the same object End Sub statement Defines the end of the macro Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Other Macro Features Statements are color-coded Visual Basic toolbar has seven buttons Customize the Visual Basic toolbar Step Into Command helps you debug a macro Opening a file with a macro will prompt a question about viruses Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 A Macro Visual Basic Editor: Project Explorer upper left; VBA code on right Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Hands-On Exercise 1 Objective: To record, run, view, and edit a simple macro; to establish a keyboard shortcut to run a macro Create a Macro Record the Macro Test the Macro Start the Visual Basic Editor Edit the Macro Create the Erase Macro Shortcut Keys Step through the Macro Print the Module Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Record Macro Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Testing the Macro Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Cell References (1 of 2) Relative versus Absolute References Critical to specify whether cell references are absolute or relative Absolute cell addresses are constant Macro refers to that cell every time the macro is run Relative cell addresses change VBA uses offset to indicate space from active cell every time the macro is run Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Cell References (2 of 2) Relative references ActiveCell.Offset(1,0).Range(“A1”).Select Relative reference above means the cell one row below the active cell Offset of (0,1) means the cell one column to the right of the active cell Negative numbers are used for cells above or to the left of the active cell Absolute references Range(“A1”).Select Always refers to cell A1 Exploring Microsoft Excel 2002 Chapter 8

Personal Macro Workbook A workbook that opens automatically whenever Excel is opened Any macro stored in this workbook can be used by any open workbook Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Hands-On Exercise 2 Objective: To create and store a macro in the Personal Macro workbook; to assign a toolbar button to a macro; to use the Visual Basic InputBox statement The Personal Macro Workbook Record with Relative References The Visual Basic Editor Edit the Macro Test the Revised Macro Add a Custom Button Test the Custom Button Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Hands-On Exercise 3 Objective: To create a data management function; to create a custom button to execute a macro Data Management Functions The Create Name Command The Go To Command Record the Macro (Edit Clear Command) Record the Macro (Advanced Filter Command) View the Macro Assign the Macro Test the Macro Exploring Microsoft Excel 2002 Chapter 8

Visual Basic for Applications VBA is a subset of Visual Basic Macros are converted to VBA programs Programs known as procedures Also called subroutines; thus the word Sub at the beginning of the macro VBA allows you to modify macros you record with the Macro Recorder Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Common VBA statements MsgBox statement Displays information to the user while the macro is executing InputBox function Accepts information from the user while the macro is executing Information is stored in a cell for use later in the procedure Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 The MsgBox Statement MsgBox statement includes the text to be displayed in the message box. The message box that appears when the macro is run is displayed below. Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 The InputBox Function InputBox statement includes the text to be displayed in the input box. The input box that appears when the macro is run is displayed below. Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Hands-on Exercise 4 Objective: To duplicate an existing macro, then modify the copied macro to create an entirely new macro Enable Macros Copy the Chicago Macro Create the Manager Macro Run the Manager Macro Assign a Button Create the Chicago Manager Macro The MsgBox Statement Exploring Microsoft Excel 2002 Chapter 8

Hands-on Exercise 4 (cont.) Test the Chicago Manager Macro Create the Any City Any Title Macro Test the Any City Any Title Macro Change the Button Properties Exploring Microsoft Excel 2002 Chapter 8

Loops and Decision Making Including IF and Do statements allows for testing IF statement tests a condition Condition must be evaluated as true or false Includes a series of commands to execute if the condition is true Includes an optional else clause with commands to execute if the condition is false DO statement repeats a block of statements until a condition becomes true Commonly called a loop Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Hands-On Exercise 5 Objective: To implement loops and decision making through the Do and If statements The ClearColor Macro Record the Highlight Manager Macro View the Macro Test the Macro Add the IF Statement An Endless Loop Complete the Macro Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Summary (1 of 2) A macro automates a repetitive task Macros are recorded using the Macro Recorder Record using either absolute or relative references Macros are written in Visual Basic for Applications programming language Generic macros should be stored in the Personal Macro workbook They will always be available to any workbook Exploring Microsoft Excel 2002 Chapter 8

Exploring Microsoft Excel 2002 Chapter 8 Summary (2 of 2) Macros are run with a toolbar, keystroke or a button Comments contain reminders to the programmer MsgBox and InputBox VBA statements make macros interactive More powerful Excel macros can be programmed with IF and DO VBA statements Exploring Microsoft Excel 2002 Chapter 8