Spreadsheet Models for Managers

Slides:



Advertisements
Similar presentations
Overview Lesson 1.
Advertisements

Excel and Visual Basic. Outline Data exchange between Excel and Visual Basic. Programming VB in Excel.
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.
Using Macros and Visual Basic for Applications (VBA) with Excel
Tutorial 8: Developing an Excel Application
1 CA202 Spreadsheet Application Combining Data from Multiple Sources Lecture # 6.
XP New Perspectives on Microsoft Excel 2003, Second Edition- Tutorial 8 1 Microsoft Office Excel 2003 Tutorial 8 – Developing an Excel Application.
Templates and Styles Excel Advanced. Templates are pre- designed and formatted spreadsheets –They provide consistency of layout/structure –They.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Lecture Excel: Multiple Worksheets. Workbook and Worksheets Multiple worksheets in a single workbook. When saved, only a single workbook (XLS) is saved.
Microsoft Excel 2003 Illustrated Complete Excel and Advanced Worksheet Management Customizing.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Word Lesson 16 Working with Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
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.
Introduction to Excel VBA University of Chicago Graduate School of Business Introduction to Computer Based Models Bus Mr. Schrage Spring 2003.
Microsoft ® Office 2007 Get up to speed with the 2007 system Murray State University College of Education:
XP New Perspectives on Introducing Microsoft Office XP Tutorial 1 1 Introducing Microsoft Office XP Tutorial 1.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
1 CS 106 Computing Fundamentals II Chapter 17 “Introduction To VBA” Herbert G. Mayer, PSU CS status 6/30/2013 Initial content copied verbatim from CS 106.
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...
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-
Applications Software. Applications software is designed to perform specific tasks. There are three main types of application software: Applications packages.
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.
Spreadsheets in Finance and Forecasting Presentation 9 Macros.
Visual Basic for Applications Macro Programming For Microsoft Office.
Intro to Excel - Session 7.31 Tutorial 7 - Session 7.3 Developing an Excel Application.
Get up to speed What’s changed, and why Yes, there’s a lot of change in Excel It’s most noticeable at the top of the window. But it’s good change.
Excel 2007 What You Should Have Learned about Excel had You Been Paying Attention.
Shannon K. Basher, MLS Houston Academy of Medicine – Texas Medical Center Library.
Spreadsheet Models for Managers: Session 14 14/1 Copyright © Richard Brenner Spreadsheet Models for Managers Session 14 Using Macros II Function.
Lesson 6 Formatting Cells and Ranges. Objectives:  Insert and delete cells  Manually format cell contents  Copy cell formatting with the Format Painter.
Chapter 2: Excel Basics and Formatting Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
1 CA202 Spreadsheet Application Automating Repetitive Tasks with Macros Lecture # 12 Dammam Community College.
Macros in Excel Using VBA Time Required – 5 hours.
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.
What’s changed, and why Lesson 1 By the end of this lesson you will be able to complete the following: Get a handle on the new look of Excel. Understand.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Excel Tutorial 8 Developing an Excel Application
Formulas and Functions
5.2 Microsoft Excel.
Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and
Spreadsheet – Microsoft Excel 2010
VBA - Excel VBA is Visual Basic for Applications
VBA - Excel VBA is Visual Basic for Applications
Excel: Macros & Pivot Tables
Microsoft Excel.
Formatting Worksheet Elements
Guide To UNIX Using Linux Third Edition
VBA (Visual Basic for Applications) What is Excel, just a spreadsheet?
Computer Fundamentals
EXCEL Introduction.
Microsoft Office Illustrated
Microsoft Excel 2003 Illustrated Complete
Learning Excel Session 9 and 10 Dr. Chaitali Basu Mukherji.
Microsoft Excel 2007 – Level 1
5.2 Microsoft Excel.
Exploring Microsoft® Excel® 2016 Series Editor Mary Anne Poatsy
Microsoft Excel All editions of Microsoft office.
Creating Macros in Excel
Exploring Microsoft Excel
Microsoft Office Ribbon
Microsoft Excel 101.
Microsoft Office Ribbon
Objectives At the end of this session, students will be able to:
Microsoft Office Excel 2003
Microsoft Excel 2007 – Level 2
Presentation transcript:

Spreadsheet Models for Managers Session 15 Spreadsheet Tools for Managers Command Macros Templates Distribution within the Enterprise Last revised: November 16, 2009

Review of last time Iteration Dynamic arrays Using the Set statement for objects

Command macros Command macros “do” things to Excel or to workbooks Define a name Color a cell blue Open a workbook Anything (almost anything) that you can do with keyboard or mouse Use the macro recorder to see what command macros look like Recorder is a fast way to learn how to do something Also use to “rough out” your macro

Example: Create a worksheet named “info” Turn on recorder, insert a new worksheet, name it “info” Stop recorder, open Visual Basic Editor But the macro recorder isn’t a very good programmer. Here’s what a programmer would write: Sub Macro1() Sheets.Add Sheets("Sheet4").Select Sheets("Sheet4").Name = "Info" End Sub Sub Macro1() Sheets.Add.Name = "Info" End Sub Usually, when you record, you’ll have some cleanup to do

Many commands aren’t recordable For an example, turn on the recorder and open a file The recorded macro opens that specific file But a common need is a command macro that enables the user to specify a file To learn about these methods and statements use these references: Excel-L discussion list Various books Sub TypicalUse() Dim theFile theFile = Application.GetOpenFilename If theFile = False Then Exit Sub <…various other steps…> End Sub

What command macros should you build? Commands that are expensive If done incorrectly If you were to train (and retrain) people to do them If people have to do them by hand So build command macros for procedures that: Are complex Are used reasonably often Must be done right One other category: doing things quickly High throughput can be a competitive asset It can enable new ways of doing business Usual structure: automatic polling of workbooks across the intranet

Presentation vs. maintenance Often we must present our data or models The needs of presentation sometimes conflict with ease of maintenance Examples: M1 M2 M3 Q1 M4 M5 M6 Q2 M7 M8 M9 Q3 M10 M11 M12 Q4 Y Q1 Q2 Q3 Q4 Y1 Q1 Q2 Q3 Q4 Y2 Q1 Q2 Q3 Q4 Y3 The above display is popular, especially with Finance It also makes maintenance difficult: The formulas for year data are often different from quarter data Edit>Fill Right is impossible Audit tools are thrown off Alternate approach: split presentation from maintenance Create the data on one sheet Display it on another Use a macro to compute display on a separate sheet Either a command macro or a function macro can work

Templates A workbook template contains infrastructure for a specific task You could have made a template for your homeworks Main application: data collection across an organization or across time Advantages Reduce setup costs Regularize data to support command macros and automation Mechanize “roll-ups” How to make a template Set up the workbook the way you want it Save as template If you save to the templates directory, it’s available in the Templates list

Enterprise templates When you distribute a template throughout the organization You can’t anticipate everything You’ll probably have to issue updates People will someday have to transfer data from the old template to the new To support updates Version stamp the template Provide macros to bring data forward to new versions Avoid having submitters enter formulas Avoid including macro tools in templates Distribute macros as add-ins instead Enables updating macros without affecting data Knowing that the data never contains macros makes virus detection easier

Macros for updating templates Typical reasons for updating templates Need a new data range Incorrect formula Need new name New value for a parameter New parameter These situations don’t affect existing data When existing data isn’t compromised, you can easily write an update macro Pull data from a workbook made from old template Insert that data into a workbook made from new template

An update macro Sub CopyData(oldWorkbook As Workbook, newWorkbook As Workbook) Dim namedRegions, i As Integer Dim rangeOld As Range, rangeNew As Range namedRegions = Array("InitialHeadcount", "Hiring", "Turnover") For i = 1 To Ubound(namedRegions) Set rangeOld = oldWorkbook.Worksheets("Sheet1") _ .Range(namedRegions(i)) Set rangeNew = newWorkbook.Worksheets("Sheet1") _ rangeNew.Value = rangeOld.Value Next i End Sub

Example: Updating a template Create a tool that asks the user to specify a source file and a destination file, and copies data from the source to the destination. The data is held in the three ranges called “InitialHeadcount”, “Hiring”, and “Turnover” Make your macro accessible by inserting a button onto the worksheet, and attaching the macro to it.

Add-Ins An Add-in is a workbook in a special format Enables you to “extend” Excel Use add-ins to distribute macros, styles, chart formats, toolbars, etc. Main advantage: you can update features without affecting user data Always version-stamp add-ins

Key bindings for macros To attach a macro to a keyboard shortcut, add this to the ThisWorkbook module: Read about the key specifiers in on-line help for VBA The macro specifier is just the name of the macro as a string Sub Workbook_Open() Application.OnKey <key-specifier>, <macro-name> End Sub Sub Workbook_BeforeClose(ignore As Boolean) Application.OnKey <key-specifier>

Tips for advanced users The defaults of some Excel options are helpful for novices But more advanced users should use different values Edit directly in cell: turn off Show Visual Basic toolbar (Excel 2003 and 2004) Add Developer>Visual Basic command to Quick Access Toolbar (Excel 2007) Manual recalculation Use templates Use chart formats

The main points Rough out your command macros using the macro recorder Many commands can’t be recorded Separate the presentation function from the maintenance function Using the Set statement for objects Use templates to collect data from the organization Avoiding putting macros in templates Distribute macro collections as add-ins

Reference readings Rob Bovey, Stephen Bullen, John Green, Robert Rosenberg, Excel 2002 VBA Programmers Reference. Birmingham, UK: 2001. Wrox Limited. On line help for VB takes some getting used to, but it is serviceable. Readings: Excel Macros in Visual Basic for Applications