Upload
sumeja
View
8
Download
1
Embed Size (px)
DESCRIPTION
Developing Spreadsheet-BasedDecision Support Systems
Citation preview
Developing Spreadsheet-Based Decision Support Systems
Using Excel and VBA for Excel
Michelle MH eref Decision and Information Sciences
Warrington College of Business, University of Florida
Ravindra K Ahuja Industrial and Systems Engineering
University of Florida
Wayne L Winston Operations and Decision Technologies
Kelly School of Business, Indiana University
2005 Seref, Ahuja, and Winston
Developing Spreadsheet-Based Decision Support Systems Seref, Ahuja, and Winston
Book Outline Part I Excel Essentials [Chapters 1 10] Part II VBA for Excel [Chapters 11 21] Part III Case Studies [Chapters 22 24 and Case Studies 1 25]
Preface xvii
Part I Excel Essentials
Chapter 1: Introduction to Decision Support Systems 3
1.1 Introduction to DSS 1.2 Defining DSS 1.3 DSS Applications 1.4 Textbook Overview
1.4.1 Overview of Excel 1.4.2 Overview of VBA for Excel 1.4.3 Overview of Case Studies
1.5 Summary
Chapter 2: Excel Basics and Formatting 14
2.1 Introduction 2.2 Defining the Set of Excel Objects 2.3 Entering data into cells 2.4 Understanding Excel menus and toolbars
2.4.1 Menus and Shortcut Keys 2.4.2 Toolbars 2.4.3 Customizing Toolbars and Menus
Table of Contents
Table of Contents
eref, Ahuja, Winston
iv
2.5 Formatting 2.5.1 Formatting Cells 2.5.2 General Formatting 2.5.3 Conditional Formatting
2.6 Summary 2.7 Exercises
Chapter 3: Referencing and Names 45
3.1 Introduction 3.2 Referencing Cells
3.1.1 Relative Referencing and Absolute Referencing 3.1.2 R1C1 Notation 3.1.3 Referencing other Worksheets and Workbooks 3.1.4 Circular References
3.2 Names for Cells, Ranges, and Worksheets 3.2.1 The Name Window 3.2.2 Define 3.2.3 Apply 3.2.4 Create 3.2.5 Formulas and Constants 3.2.6 Natural Range Names
3.3 Summary 3.4 Exercises
Chapter 4: Functions and Formulas 76
4.1 Introduction 4.2 Formulas and Function Categories 4.3 Logical and Information Functions 4.4 Text and Lookup and Reference Functions 4.5 Date and Time Functions 4.6 Mathematical and Trigonometry Functions 4.7 Statistical and Financial Functions 4.8 Conditional Formatting Formulas 4.9 Auditing 4.10 Summary 4.11 Exercises
Chapter 5: Charts 141
5.1 Introduction 5.2 Creating Charts with the Chart Wizard 5.3 Working with Chart Options 5.4 Creating Dynamic Charts 5.5 Summary
Table of Contents
eref, Ahuja, Winston
v
5.6 Exercises
Chapter 6: Pivot Tables 167
6.1 Introduction 6.2 Pivot Tables
6.2.1 Terminology 6.2.2 Creating a Pivot Table
6.3 Further modifications 6.3.1 Pivot Table Toolbar and Options 6.3.2 Grouping 6.3.3 Calculated Fields and Items 6.3.4 GETPIVOTDATA Function
6.4 Pivot Charts 6.5 Summary 6.6 Exercises
Chapter 7: Statistical Analysis with Excel 193
7.1 Introduction 7.2 Understanding Data
7.2.1 Descriptive Statistics 7.2.2 Histograms
7.3 Relationships in Data 7.3.1 Trend Curves 7.3.2 Regression
7.4 Distributions 7.5 Summary 7.6 Exercises
Chapter 8: The Excel Solver and Mathematical Programming 253
8.1 Introduction 8.2 Formulating Mathematical Programs
8.2.1 Parts of the Mathematical Program 8.2.2 Linear, Integer, and Nonlinear Programming
8.3 Excel Solver 8.3.1 The Solver Steps
8.3.1.1 Infeasibility 8.3.1.2 Unboundedness
8.3.2 Understanding Solver Reports 8.4 Applications of the Solver
8.4.1 Transportation Problem 8.4.2 Workforce Scheduling 8.4.3 Capital Budgeting 8.4.4 Warehouse Location
8.5 Summary 8.6 Exercises
Table of Contents
eref, Ahuja, Winston
vi
Chapter 9: Simulation Using Excel 298
9.1 Introduction 9.2 Defining Simulation
9.2.1 Data Tables 9.2.2 Scenario Manager 9.2.3 Generating Random Numbers within Distributions
9.3 Applications 9.3.1 Newsvendor Problem 9.3.2 Game of Craps 9.3.3 Bidding
9.4 Summary 9.5 Exercises
Chapter 10: Working with Large Data 331
10.1 Introduction 10.2 Importing Data
10.2.1 Text Files 10.2.2 Web Addresses 10.2.3 Databases
10.3 Exporting Data 10.4 Creating Pivot Tables from External Data 10.5 Using Excel as a Database
10.5.1 Sorting 10.5.2 Filtering 10.5.3 DFunctions 10.5.4 Data Validation 10.5.5 Data Consolidation
10.6 Summary 10.7 Exercises
Part II - VBA for Excel
Chapter 11: Introduction to the Visual Basic Environment 386
11.1 Introduction 11.2 The Visual Basic Editor
11.2.1 Project Explorer 11.2.2 Properties Window 11.2.3 Code Window 11.2.4 Immediate and Watch Windows 11.2.5 VBE Toolbars
11.3 The Object Browser 11.3.1 Properties and Methods 11.3.2 Libraries, Classes, and Members
11.4 Summary
Table of Contents
eref, Ahuja, Winston
vii
11.5 Exercises
Chapter 12: Recording Macros 395
12.1 Introduction 12.2 Macros
12.2.1 Recording Macros 12.2.2 The VBA Code 12.2.3 Event Procedures
12.3 Customizing toolbars and menu options 12.4 Summary 12.5 Exercises
Chapter 13: More on Objects 429
13.1 Introduction 13.2 Objects and their properties and methods
13.2.1 Workbooks and worksheets 13.2.2 Ranges 13.2.3 Charts 13.2.4 Drawing objects 13.2.5 Application
13.3 The With construct 13.4 Referencing in VBA
13.4.1 Referencing ranges and cells 13.4.2 Naming ranges 13.4.3 Naming other Excel objects
13.5 Formulas in VBA 13.5.1 Using ranges and cells 13.5.2 Using the Application object
13.6 Summary 13.7 Exercises
Chapter 14: Variables 497
14.1 Introduction 14.2 Variable Declarations and Data Types
14.2.1 Integer and Double 14.2.2 String 14.2.3 Boolean 14.2.4 Constant 14.2.5 Range 14.2.6 Worksheets 14.2.7 Object
14.3 Variable scope 14.3.1 Public and private declarations 14.3.2 Keeping track of variable values
14.4 Variables in User Interface
Table of Contents
eref, Ahuja, Winston
viii
14.4.1 Message Box 14.4.2 Input Box
14.5 VBA Math Functions 14.5.1 Typical Math Functions 14.5.2 Trigonometric Functions 14.5.3 Derived Math Functions 14.5.4 Conversion Functions 14.5.5 String Functions
14.6 Applications 14.6.1 Creating and Modifying Shapes 14.6.2 Making Calculations and Creating a Report
14.7 Summary 14.8 Exercises
Chapter 15: Subroutines and Functions 538
15.1 Introduction 15.2 Sub Procedures
15.2.1 Calling other sub procedures 15.2.2 Passing variables in procedures
15.3 Function Procedures 15.3.1 Passing variables in functions
15.4 Public and private procedures 15.5 Applications
15.5.1 Navigating functions 15.5.2 Derived math functions
15.6 Summary 15.7 Exercises
Chapter 16: Programming Structures 558
16.1 Introduction 16.2 If, Then Statements
16.2.1 Logical checks and Booleans 16.3 Select, Case 16.4 Loops
16.4.1 For Loops 16.4.2 Do Loops
16.5 Exit Statements and End 16.5.1 Exiting Procedures 16.5.2 Exiting Loops 16.5.3 Ending the Program
16.6 Applications 16.6.1 Banking Account Management
16.7 Summary 16.8 Exercises
Table of Contents
eref, Ahuja, Winston
ix
Chapter 17: Arrays 589
17.1 Introduction 17.2 When and why to use arrays 17.3 Defining arrays
17.3.1 Multidimensional Arrays 17.3.2 Indexing
17.4 Dynamic arrays 17.5 Sorting arrays 17.6 Applications
17.6.1 Phonebook 17.7 Summary 17.8 Exercises
Chapter 18: User Interface 610
18.1 Introduction 18.2 User Form Controls
18.2.1 Labels and Text boxes 18.2.2 Combo Boxes and List Boxes 18.2.3 Check Boxes, Option Buttons, and Toggle Buttons 18.2.4 Command buttons 18.2.5 Tab Strips and Multi Pages 18.2.6 Scroll bars and Spin buttons 18.2.7 Images and RefEdit
18.3 User Form Options 18.4 Event Procedures 18.5 Variable Scope 18.6 Error Checking 18.7 Importing and Exporting Forms 18.8 Navigating 18.9 Professional Appearance
18.9.1 Protecting the Worksheet 18.9.2 Sheet Options
18.10 Applications 18.10.1 Real Estate Search Spreadsheet Application 18.10.2 Product Search Form
18.11 Summary 18.12 Exercises
Chapter 19: The Solver Re-Visited 662
19.1 Introduction 19.2 Review of Chapter 8
19.2.1 Understanding the problem 19.2.2 Preparing the worksheet 19.2.3 Solving the Model
Table of Contents
eref, Ahuja, Winston
x
19.3 Solver commands in VBA 19.3.1 Identifying Solver Input 19.3.2 Setting Solver options 19.3.3 Running the solver 19.3.4 Generating reports
19.4 Application 19.4.1 Dynamic Production Problem
19.5 Summary 19.6 Exercises
Chapter 20: Simulation Re-Visited 688
20.1 Introduction 20.2 Review of Chapter 9
20.2.1 Defining Simulation 20.2.2 Working with Distributions
20.3 Simulation with VBA 20.3.1 Random Numbers and Distributions 20.3.2 Making Runs and Collecting Data 20.3.3 Animation 20.3.4 Analysis
20.4 Application 20.4.1 Game of Craps Re-visited
20.5 Summary 20.6 Exercises
Chapter 21: Working With Large Data in VBA 709
21.1 Introduction 21.2 Creating Pivot Tables with VBA 21.3 Using External Data
21.3.1 Importing Data 21.3.1.1 Text files and Webpages 21.3.1.2 Databases
21.3.2 Performing Queries with SQL 21.4 Exporting Data 21.5 Applications
21.5.1 Transcript Query 21.6 Summary 21.7 Exercises
Part III - Case Studies
Chapter 22: The DSS Development Process 751
22.1 Defining the DSS Development Process 22.2 Application Overview and Model Development
Table of Contents
eref, Ahuja, Winston
xi
22.2.1 Input 22.2.2 Model and Calculations 22.2.3 Output 22.2.4 Re-solve Options
22.3 Worksheets 22.3.1 Welcome Sheet 22.3.2 Input Sheet 22.3.3 Model and Calculations Sheet 22.3.4 Output Sheet
22.4 User Interface 22.4.1 Navigational Buttons 22.4.2 Receiving Input
21.4.2.1 Form Controls on the Worksheet 21.4.2.2 User Forms
22.4.3 Functional Buttons 22.5 Procedures
22.5.1 Receiving Input 22.5.2 Model and Calculations 22.5.3 Output Analysis and Display 22.5.4 Navigational
22.6 Re-solve Options 22.7 Testing and Final Packaging 22.8 Summary 22.9 Exercises
Chapter 23: GUI Design 800
23.1 GUI Design 23.2 The Theory Behind Effective GUI Design
23.2.1 Users, Tasks, and Goals 23.2.2 Clarity 23.2.3 Consistency
23.3 Effective and Ineffective GUI Designs 23.3.1 Buttons 23.3.2 Text Boxes versus List Boxes and Combo Boxes 23.3.3 Tab Strips and Multi Pages 23.3.4 Check Boxes versus Option Buttons 23.3.5 Frames 23.3.6 Labels versus Text Boxes 23.3.7 Dynamic Controls 23.3.8 Multiple Forms 23.3.9 Event Procedures
23.4 Summary 23.5 Exercises
Table of Contents
eref, Ahuja, Winston
xii
Chapter 24: Programming Principles 830
24.1 Programming Practices 24.2 Clarity
23.2.1 Consistent Style 23.2.2 Naming 23.2.3 Documentation
24.3 Efficiency 24.4 Summary 24.5 Exercises
Case Study 1: Eight Queens 850
Case Study 2: Projectile 870
Case Study 3: Birthday Simulation 890
Case Study 4: Poker Simulation 910
Case Study 5: NBA Lineup 930
Case Study 6: University Student Information System 950
Case Study 7: Retirement Planning 970
Case Study 8: Stochastic Customer Forecasting 990
Case Study 9: Sales Force Allocation 1010
Case Study 10: Technical Analysis 1030
Case Study 11: Beta of Stocks 1050
Case Study 12: Option Pricing 1070
Case Study 13: Supply Chain Management 1090
Case Study 14: Inventory Management 1110
Case Study 15: Forecasting Methods 1130
Table of Contents
eref, Ahuja, Winston
xiii
Case Study 16: Capital Budgeting 1150
Case Study 17: Portfolio Management and Optimization 1170
Case Study 18: Reliability Analysis 1190
Case Study 19: Queuing Simulation: Single Server and Multi Server 1210
Case Study 20: Facility Layout 1230
Case Study 21: Warehouse Layout 1250
Case Study 22: Critical Path Method with Time-Cost Tradeoff 1270
Case Study 23: Kruskals Algorithm 1290
Case Study 24: The Simplex Algorithm 1310
Case Study 25: IMRT 1330
Appendices
Appendix A: Excel Add-Ins 1333
A.1 Analysis Toolpack A.2 Premium SolverIntroduction A.3 Data Analysis Toolpack A.4 The Solver
A.4.1 Excel Standard Solver A.4.2 Frontline Premium Solver A.4.3 Limitations and Manipulations of the Solver
A.5 @RISK A.6 Crystal Ball A.7 StatTools A.8 Summary
Appendix B: Debugging and Error Checking 1355
B.1 Types of Errors B.2 The Debug Toolbar
B.2.1 Step-Into B.2.2 Step-Over B.2.3 Step-Out
Table of Contents
eref, Ahuja, Winston
xiv
B.2.4 Run-To-Cursor B.2.5 Breakpoints
B.3 The Debug Windows B.3.1 Watch Window B.3.2 Immediate Window
B.4 Debugging tips B.5 Error Checking
B.5.1 Review of some techniques B.5.2 Is Functions B.5.3 On Error, Resume Next B.5.4 On Error, Go To B.5.5 Err Object
B.6 Summary
Appendix C: Advanced Programming Topics 1377
C.1 Introduction C.2 Object Oriented Programming in VBA for Excel
C.2.1 Class Modules C.2.2 Defining Properties C.2.3 Defining Methods C.2.4 Defining Events C.2.5 Using New Class Objects
C.3 Opening Other Applications From VBA C.3.1 Starting an Executable Program C.3.2 Writing, Appending to, and Reading a File C.3.3 Starting a Microsoft Application
C.4 Summary
Index 1400
References 1410