Chapter 9 Macros And Visual Basic For Applications.

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.
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
© 2002 ComputerPREP, Inc. All rights reserved. Excel 2000: Customizing Excel and Using Macros.
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.
Working with Large Worksheets, Charting, and What-If Analysis
Automating Tasks With Macros
String Variables Visual Basic for Applications 4.
Microsoft Excel 2003 Illustrated Complete with Excel Programming.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Macros Excel built-in functions are great but limited Macros are a means for the user to define new functions A macro is a single command that automates.
Chapter 1 Introduction to Spreadsheet. Agenda Download the practice files Spreadsheet application Workbook and worksheet Toolbar Cell Formatting Printing.
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)
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Week 1.  Kate Watson  Checked at least every other day. Queries and general comments welcome.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module M Programming in Excel with VBA.
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.
VBA (Visual Basic for Applications) What is Excel, just a spreadsheet? Time for Demos...
© McGraw-Hill Companies, Inc., McGraw-Hill/Irwin Extended Learning Module M Programming in Excel with VBA.
VBA for Excel. What is a spreadsheet? u An Excel spreadsheet is a set of worksheets  Each worksheets is made up of rows and columns of cells  Rows are.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module M Programming in Excel with VBA.
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-
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.
University of Toronto at Scarborough © Andria Hunter, Kersti Wain-Bantin CSCA01 VBA 1 Lecture Outline Record macro and examine VBA code VBA Editor (IDE)
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Lecture Excel: Macros & Pivot Tables. Macros A macro is a series of commands that are stored and can be run whenever you need to perform the task.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Visual Basic for Applications Macro Programming For Microsoft Office.
Intro to Excel - Session 7.31 Tutorial 7 - Session 7.3 Developing an Excel Application.
OCC Network Drives  H:\  P:\ 
# 1# 1 CS 105 Spring 2010 Macros: Sub Procedures You Record What is a macro? What is With…End With? What is Sub…End Sub? Relative vs. Absolute.
Chapter 3 The Visual Basic Editor. Important Features of the VBE Alt-F11 will open the Visual Basic Editor. The Code window is to the right, Project Explorer.
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.
Visual Basic Objects / Properties / Methods PropertyAdjective ObjectNoun Part of the application Attribute MethodVerb Action to do something.
VBA Navigation, Conditionals, and Boxes. VBA Navigation.
Chapter 2: Excel Basics and Formatting Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
Chapter 3 Graphs and Charts. Agenda Chart Object linking and embedding.
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.
VBA Excel Macro 1.Create a Macro: To create a macro in Excel VBA, Create a Macro: To create a macro in Excel VBA,Create a Macro: To create a macro.
The Advantage Series ©2005 The McGraw-Hill Companies, Inc. All rights reserved Chapter 12 Introducing Visual Basic for Applications Microsoft Office Excel.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Excel Tutorial 8 Developing an Excel Application
Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and
Excel: Macros & Pivot Tables
VBA (Visual Basic for Applications) What is Excel, just a spreadsheet?
Microsoft Office Illustrated
Microsoft Excel 2003 Illustrated Complete
Learning Excel Session 9 and 10 Dr. Chaitali Basu Mukherji.
Introducing VBA Macros
Exploring Microsoft Excel
Lesson 1 - Automating Tasks
Microsoft Excel 2007 – Level 2
Presentation transcript:

Chapter 9 Macros And Visual Basic For Applications

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

Macro Macro storing Excel commands (written in Visual Basic for Applications) Visual Basic Editor (VBE) creating, displaying, running, and debugging macro commands Project Explorer locating macro modules Code window displaying micro statements

Macro Statements Sub (subroutine) statement followed by the name of the macro –Defining the beginning of the macro Comments begin with apostrophe (’) –Providing documentation End Sub statement –Defining the end of the macro

The With Block Including With and End With Performing multiple actions on the same object

Absolute Cell References Referring to a specific cell Referred to by cell address or by range name Syntax: Range(“A1”).Select –Always selecting cell A1

Relative Cell Reference (I) Referring to a cell by its position relative to the active cell Offset: giving the position relative to the active cell –First number: indicating the offset in rows A positive number: rows below the active cell –Second number: indicating the offset in columns A positive number: columns to the right of the active cell –Offset (2, 3) always refers to a cell two rows below and three columns to the right of the active cell

Relative Cell Reference (2) Range: dimensions of cell(s) –Range(“A1”): a single cell –Range(“A1:A3”): a range three rows by one column Syntax: ActiveCell.Offset(2,1).Range(“A1”). Select –Always selecting a single cell two rows below and one column to the right of the active cell

Data Management Macro Automating data list management tasks –Prompting user for input to populate a criteria range –Filtering list or displaying database functions based on those criteria Use range name for the list or the criteria range

Visual Basic for Applications Tool menu, Macro, Visual Basic Editor –Or Alt+F11 VBA: a subset of Visual Basic Macro converted to VBA programs Creating macro using macro recorder Using Visual Basic Editor to modify

Custom Button – Standard Toolbar Creating custom button: Tools menu, Customize, Command tab, selecting Macro for the category, dragging custom button to the standard toolbar, selecting Modify Selection button, typing the name to replace “&name button” (do not press enter”, selecting Assign Macro to assign a macro, selecting This Workbook for Micro in, selecting Close Deleting a micro and its custom button: –Tools menu, Micro, selecting micro name, clicking Delete button –Dragging the corresponding custom button from the standard toolbar to the worksheet area

Custom Button – Worksheet Creating: –View Menu, Toolbars, Forms, clicking Button tool, drawing a button, assigning a associated macro, typing the name for the button Selecting –Ctrl key and clicking the button (releasing the Ctrl key right away) Coping –Holding Ctrl key and clicking the button (+ sign) Deleting the macro and its corresponding micro –Tools menu, Macro, selecting the macro name, clicking Delete button, OK (performing this first) –Selecting the custom button, right clicking the mouse, selecting Cut

Common VBA statements Underscore and ampersand: continuation MsgBox statement –Displaying information to the user InputBox statement –Accepting information from the user –Storing information in a cell or memory for future usage in the program

Decision Making “If-Then-Else-End If” statement If testing a condition (true or false) “Then” clause including a series of commands to execute for the true condition –Then clause is necessity “Else” clause including commands to execute for the false condition –Else clause is optional Ends with End If statement

Loops Do Until -Loop statement –Executing statements repeatedly Begin with Do Until statement –Including a true or false condition after the Until for evaluating End with Loop statement Executing between Do and Loop statements repeatedly until the condition is true

Points to Remember Personal Macro workbook Macro Visual Basic Editor VBA statements –Information: MsgBox and InputBox –Decision making: If –Repeating: Do

Assignment Practice exercises 7 and 8 Due date: