 An object-oriented programming language ◦ Instructions for the manipulation of objects ◦ A structured way to provide instructions to Excel  Excel has.

Slides:



Advertisements
Similar presentations
1 Overview Introduction to VBA The Visual Basic Editor (VBE) –First Program Getting Started with VBA –Subroutines –Declaring variables –Input boxes and.
Advertisements

Visual Basic for Applications (VBA) An object-oriented programming language –Instructions for the manipulation of objects –A structured way to provide.
ISOM3230 Business Applications Programming
© Paradigm Publishing, Inc Excel 2013 Level 2 Unit 2Managing and Integrating Data and the Excel Environment Chapter 7Automating Repetitive Tasks.
Object Oriented Programming A programming concept which views programs as objects with properties and ways to manipulate the object and the properties.
Essence of programming  Branching  Repetitions.
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.
Using Macros and Visual Basic for Applications (VBA) with Excel
Some computer fundamentals and jargon Memory: Basic element is a bit – value = 0 or 1 Collection of “n” bits is a “byte” Collection of several bytes is.
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
VBA for MS Excel Hamze Msheik. Open the Visual Basic Editor in Excel 2007 Click on the Microsoft Office button in the top left of the Excel window and.
Excel and VBA Creating an Excel Application
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
Adding Automated Functionality to Office Applications.
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Visual Basic for Applications (VBA) An object-oriented programming language –Instructions for the manipulation of objects –A structured way to provide.
Chapter 8: String Manipulation
Using the Select Case Statement and the MsgBox Function (Unit 8)
IE 212: Computational Methods for Industrial Engineering
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module M Programming in Excel with VBA.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #4: Working with Variables and User Interfaces IE 212: Computational Methods for Industrial Engineering.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
© McGraw-Hill Companies, Inc., McGraw-Hill/Irwin Extended Learning Module M Programming in Excel with VBA.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module M Programming in Excel with VBA.
Mr C Johnston ICT Teacher BTEC IT Unit 06 - Lesson 05 Learning To Program.
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-
Creating Macros Using VBA. Assigning a Macro to a Button Display the Forms toolbar. Click the Button icon. Click and drag the mouse pointer to specify.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
OV Copyright © 2011 Element K Content LLC. All rights reserved.  Create a Macro with the Macro Recorder  Edit a Macro  Debug a Macro  Customize.
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
Visual Basic for Applications Macro Programming For Microsoft Office.
Visual Basic for Applications (VBA) An object-oriented programming language –Instructions for the manipulation of objects –A structured way to provide.
Intro to Excel - Session 7.31 Tutorial 7 - Session 7.3 Developing an Excel Application.
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.
Week 2.  Macros revisited  The VBA Editor  The object model  Using variables  If statements.
Lab 4 Range Review, Control Logic and Loops ► Range Review ► Control Logic and Loops ► Exercise.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Chapter 9 Macros And Visual Basic For Applications.
ME 142 Engineering Computation I Using Subroutines Effectively.
Lab 2 Introduction to VBA (II) ► Lab 1 revisited - Sub & Function procedures - Data types and variable declaration ► Recording.
Lab 6 (2) Arrays ► Lab 5 (1) Exercise Review ► Array Concept ► Why Arrays? ► Array Declaration ► An Example of Array ► Exercise.
Chapter 11: Introduction to VBA Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Running Solver through a Macro Solver dialog box must have been opened at least once in current Excel session (i.e. Solver must be currently activated.
ME 142 Engineering Computation I Using Subroutines Effectively.
# 1# 1 What is a variable that you create? What is a constant that you create? What is an intrinsic (built-in) constant? What variables are built in?
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 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
Subroutines and Functions Chapter 6. Introduction So far, all of the code you have written has been inside a single procedure. –Fine for small programs,
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Macros in Excel Using VBA Time Required – 5 hours.
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.
Introduction to Programming Lecture 2
IE 8580 Module 4: DIY Monte Carlo Simulation
A variable is a name for a value stored in memory.
Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and
VBA - Excel VBA is Visual Basic for Applications
Microsoft Office Illustrated
Variables and Arithmetic Operations
Exploring Microsoft Excel
CHAPTER FOUR VARIABLES AND CONSTANTS
Lesson 1 - Automating Tasks
The structure of programming
Microsoft Excel 2007 – Level 2
Presentation transcript:

 An object-oriented programming language ◦ Instructions for the manipulation of objects ◦ A structured way to provide instructions to Excel  Excel has an Object Library that defines its set of objects (e.g. workbooks, charts, ranges of cells)

 First part of a command identifies the object  Second part of command: ◦ Sets a property of the object (e.g. color or font) ◦ Takes an action on the object (e.g.copy or move) ◦ Sets an attribute to the object (e.g. assigns a value to it using := )

 Application.Workbooks(“Book1.xls”). Worksheets(“Sheet1”).Range(“A1”).Font. Name=“Arial” ◦ Application.Workbooks(“Book1.xls”). Worksheets(“Sheet1”).Range(“A1”) is the object ◦ Font.Name=“Arial” is the property being set

 A Procedure is a set of instructions that operate on a set of objects ◦ A Function is a procedure that returns a value as a result ◦ A Subroutine is a procedure that can be run or used by another macro

Sub bluecell() ' ' bluecell Macro ' With Selection.Interior.Pattern = xlSolid.PatternColorIndex = xlAutomatic.Color = TintAndShade = 0.PatternTintAndShade = 0 End With End Sub

 Used to overcome long lines of repetitive code that can arise when using full references to objects  The construct allows for repeated referral to the same object and thereby reduces the amount of code  Selection.Interior is the object and the next five lines before the End With represent the different properties being set for this object.

 Run Macro option  Shortcut Keys: [Ctrl][Shift] letter  Command Buttons  Custom Toolbar

 Variables contain values ◦ X= 3000 ◦ UnitCost = 1.20 ◦ Output1 = “npv”  Each variable has a location in memory where its value is stored  If a variable is on left side of the equal sign, then the variable’s new value in memory is changed to whatever is on right side  If a variable is on right side of the equal sign, then the variable’s value will not change but its value will be assigned to another variable or object.

 Declare all variables at beginning of each procedure with the keyword Dim ◦ Catches spelling problems later on and helps debug problems ◦ Allows you to specify type of variable:  String (for names like “npv”)  Integer  Single (for numbers with decimals)  Currency  Boolean (for True/False) ◦ Uses memory better and allows variable to be used in its appropriate context

 Function name(parameter1, parameter 2,…) …Code…. name= result End Function  Example:  Function betapert(prob,min,mostlikely,max) …Code…. betapert= Application.BetaInv(…..) End Function

 When VBA encounters a problem, it will highlight line in yellow.  Use [f8] key to step through code  Use the Reset icon button (square) at top of VBA to exit step-through mode and trouble- shoot code or Excel/VBA settings. Cannot retry macro until yellow highlight is gone.