Developing an Excel Applications

Slides:



Advertisements
Similar presentations
Object Oriented Programming A programming concept which views programs as objects with properties and ways to manipulate the object and the properties.
Advertisements

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.
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
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.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
How to get started with Excel VBA. We need to enable programming in Excel  the “Developer menu”
Writing VBA Macros Record a new Macro, recording only the name, shortcut and description Stop recording Open macro for editing and enter VB code Test.
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.
VBA Programming Session #2. Things to Review  Variables  Procedures: Subs & Functions  If…Then  For…Next.
Lecture Excel: Multiple Worksheets. Workbook and Worksheets Multiple worksheets in a single workbook. When saved, only a single workbook (XLS) is saved.
Chapter 12: Recording Macros Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Macros in Excel Intro to lab 1. Macroinstructions Macro is recorded in VBA module sequence of Excel operations Macros can automate tasks in Excel Macro.
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Lecture Roger Sutton CO357 Computing for Business and Accounting 13: Automation and Control (Macros and Form controls ) 1.
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...
11 10/10/2005 BAE Spreadsheet Macros (Visual Basic for Applications) Slides to accompany an in-class demo of spreadsheet technique: Macro Programming.
© 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.
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
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.
Introduction to VBA MGMI Aug What is VBA? VBA = Visual Basic for Application Excel’s powerful built-in programming language An event-driven.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
Week 8.  Recap  User Forms  Input Validation Message Boxes Input Boxes  Conversion Functions.
University of Toronto at Scarborough © Andria Hunter, Kersti Wain-Bantin CSCA01 VBA 1 Lecture Outline Record macro and examine VBA code VBA Editor (IDE)
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
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.
Visual Basic for Applications Macro Programming For Microsoft Office.
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.
Course ILT Excel basics Unit objectives Start Excel; open, save, and create new workbooks; work with multiple workbooks; get help; and close a workbook.
Chapter 9 Macros And Visual Basic For Applications.
Chapter 11: Introduction to VBA Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Controls and Events. The Next Step In the first module, we discussed general problem solving In this module, we’ll apply what we learned, from specification.
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.
Excel Macros 1 Macros or, How to Automate Part of Your Spreadsheet or Worksheet.
Visual Basic Objects / Properties / Methods PropertyAdjective ObjectNoun Part of the application Attribute MethodVerb Action to do something.
Chapter 2: Excel Basics and Formatting Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
How to Create a form using the Program Excel By Mrs Douglas 8/1/10.
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.
Excel Tutorial 8 Developing an Excel Application
Outline In this module, the following topics will be covered:
Excel: Macros & Pivot Tables
VBA (Visual Basic for Applications) What is Excel, just a spreadsheet?
Microsoft Office Illustrated
Excel VBA Day 3 of 3 Tom Vorves.
Microsoft Excel 2003 Illustrated Complete
Learning Excel Session 9 and 10 Dr. Chaitali Basu Mukherji.
Introducing VBA Macros
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
Lesson 1 - Automating Tasks
Microsoft Office Excel 2003
Tutorial 11 Using and Writing Visual Basic for Applications Code
Presentation transcript:

Developing an Excel Applications By Prof. H-M. Haav

For creating an application one needs Macros Modules Controls

Macros can be created in two ways: Recording plan actions you need to automate Tools>Record a new macro perform actions you need to automate stop recording Writing macros in VBA Tools>macros

Visual Basic for Applications VBA 1. Structure of Procedure (module) Sub name_of_program (parameters,…) <statements> ….. End sub

2. Reading data from active sheet variable = cell (reading one value) S = S=Range(“A1”) S=Range (“Start”) S=Cells(1,1) Cells(row index, column index) returns value of specified cell

2. Writing data to active sheet range = expression Cells(1,1) = 5 Range(“A1”) = “last name” Range (“Start”) = “last name” Cells(1,2) = SUM (B1:B7)

Naming ranges is useful for creating programs in VBA Sheets(“Sheet name”).Range(“Start”)

4. Dialog Boxes allow dialog with end-user of an application Sub computer (optional Year) Year =InputBox(“Input year of craetion of the first PC”) If Year = 1976 Then msg=“True!” Else msg=“False!” MsgBox msg End Sub

Objects and classes in Excel Application Command bars dialog Workbook(s) chart windows Chart objects Worksheet(s) Shape(s) Range

References to objects Workbooks(“BananaMadness.xls”) Worksheets(“Title Sheet”) Sheets(1) ActiveWorkbook.Sheets(3) Rows(3) Columns(1) Range(“Starts”).Cells (all cells in the range)

Properties of objects Object.[property] x=Range(“Starts”).value assigns variable x a value of range called Starts .ActiveSheet .ActiveCell .Selection Range(“Starts”).CurrentRegion …etc

Methods of objects Object.method[arguments] Worksheet(“Title Sheet”).Select Worksheet(“Title Sheet”).Activate Worksheet(“Title Sheet”).Calculate Worksheet(“Title Sheet”).Delete Range(“Starts”).Clear …etc

Controls Button Radio button Combo box To create a control turn on Forms toolbar select the control drag the control to needed area define properties

Assign macro to a control select the control on Tools menu, click Assign Macro enter or choose the name of your existing macro

Examples of recorded macros Sub TotalBonus() Range("I7").Select ActiveCell.FormulaR1C1 = "=SUM(RC[-2]:RC[-1])" Selection.AutoFill Destination:=Range("I7:I10"), Type:=xlFillDefault Range("I7:I10").Select Selection.Style = "Currency" End Sub