How This Book Is Organized. 9. Part One Excel for Financial Analysis and
Modeling. CHAPTER 2. Excel 2007 and the Previous Versions. The New
Features in ...
Using Excel and VBA SECOND EDITION
CHANDAN SENGUPTA
WILEY John Wiley & Sons, Inc.
Contents
About This Book CHAPTER 1
xix Introduction to Hnancial Analysis and Modeling Steps in Creating a Model How This Book Is Organized
1 5 9
Part One Excel for Financial Analysis and Modeling CHAPTER 2
Excel 2007 and the Previous Versions
The New Features in Excel 2007 The New User Interface The Office Icon The Ribbon The Quick Access Toolbar (QAT) and Customizing It The Shortcut Menus and the Mini Toolbar Finding Some of the Old Tools and Dialog Boxes Other New Features PivotTable Table Professional Quality Charts Conditional Formatting AutoComplete for Entering Formulas One Integrated Function Library Styles and Themes A Much Larger Grid Page Layout View Consolidated Options New File Formats in Excel 2007
15
15 16 17 17 18 19 19 19 20 20 21 21 21 22 22 22 23 23 23
vii
CONTENTS
CHAPTER 3
CHAPTER 4
Excel Basics
25
Improving Your Excel Skills Saving Your Workbooks Using Excel's Online Help Learning Excel Features The Basic Excel Features Keeping Your Workbooks and Related Files Organized Naming Workbooks and Worksheets Finding the Commands You Need Working with Worksheets Working with Rows, Columns, and Cells Using the Toolbars Using Keyboard Shortcuts Navigating the Worksheet Formatting Entering and Working with Formulas Using Paste Special Controlling the Worksheet View Using Undo and Redo Customizing the Excel Work Environment Controlling When Formulas Are Calculated Printing Creating Charts Working with More Than One Workbook Using the Scroll Lock
26 26 28 32 32
Advanced Excel Features Copying Formulas Using Absolute and Relative Cell References Creating Names for Cells and Ranges Using Names in Formulas Al and R1C1 Reference Styles Using Comments in Cells Data Validation Controls Custom Number Formats Hiding and Protecting Custom Views Arrays and Array Formulas Outline
43
32 33
33 33 34 34 34 36 36 37 37 38 38 38 39 39 40 40 41
46 49 56 57 58 60 62 65 67 71 72 75
ix
Contents
CHAPTER 5
CHAPTER 6
CHAPTER 7
CHAPTER 8
Making Oecisions and Looking Up Values Making Decisions Examples of Creating Decision-Making Formulas Looking Up Values Conditional Formatting
78 82 97 103
Analyzing Databases The Mutual Fund Portfolio v Sorting Sorting on One Field Sorting Using Custom Lists Multiple Sort Filtering Filtering on a Single Column Filtering on Multiple Columns Combining Filtering and Sorting Tables Creating a Table Working with a Table Adding and Using a Total Row Removing Duplicate Data Rows from a Table Sorting and Filtering a Table Using Structured References with Tables PivotTable The Basic Structure of a Pivot Table Creating a Basic Pivot Table Formatting a Pivot Table Modifying Pivot Tables Grouping Fields Sorting and Filtering Pivot Tables Other Features of PivotTable
110 112 113 115 118 120 121 122 124 124 126 127 129 132 132 133 135 136 138 142 145 151 156 159
Answering What-lf Questions Data Tables Scenario Manager
162 166
Finding Iterative Solutions Circular Reference Goal Seek Solver
171 174 177
77
109
161
171
CONTENTS CHAPTERS
Doing Statistics! Analysis Descriptive Statistics Frequency Distributions and Histograms Counting, Ranking, and Calculating Quantiles Normal Probability Distributions Random Numbers Statistical Tests
185 187 192 195 203 207 218
CHAPTER 10 Using the Hnancial Frictions Annuity Functions Investment Analysis Functions Bond Functions Depreciation Functions
221 228 232 237
CHAPTER 11 Other Useful Excel Functions Mathematical Functions Truncating and Rounding Numbers Logarithms Other Mathematical Functions Date and Time Functions Text Functions Information Functions
243 243 243 246 246 248 251 254
221
Part Two Financial Modeling Using EKcel 257
CHAPTER 12 Building ted Excel Models and Debugging Them Attributes of Good Excel Models Documenting Excel Models Common Ways to Document Your Excel Model Debugging Excel Models Errors Excel May Find for You Errors You Will Have to Find Yourself Using Formula Auditing Tools for Debugging The Formula Auditing Tools Learning Modeling Using Excel The Four Learning Tracks
257 260 260 262 263 264 265 266 267 267
CHAPTER 13 Financial Statements Forecasting Review of Theory and Concepts Step 1: Understand the Expected Uses of the Model Step 2: Collect Historical Data
271 272 272
271
Contents
Ki
Step 3: Understand the Company's Plans and Develop a Comprehensive Set of Modeling Assumptions Step 4: Build the Model and Debug It Step 5: Improve the Model Based on Feedback The Level of Detail in a Model The Statement of Cash Flows Free Cash Flow Modeling Examples : Model 1: Historical Financial Statements Model 2: Common Size Statements Model 3: Financial Indicators Model 4: Financial Statement Forecasting with Unbalanced Balance Sheet Model 5: Financial Statement Forecasting, Version 1 Model 6: Financial Statement Forecasting, Version 2 Model 7: Financial Statement Forecasting, Version 3 Model 8: Financial Statement Forecasting, Version 4 Model 9: Financial Statement Forecasting, Version 5 Model 10: Financial Statement Forecasting, Version 6 Model 11: Financial Statement Forecasting, Version 7 Model 12: Financial Statements Sensitivity Analysis Model 13: Financial Statements Scenario Analysis Model 14: Calculating Free Cash Flow CHAPTER 14 Time Value of Money
Review of Theory and Concepts Present and Future Values Investment and Project Evaluation Constant Annuities • Growing Annuities Modeling Examples Model 1: Effect of Compounding Frequency Model 2: Constant Annuities
273 275 276 277 277 279 281 281 288 290 293 300 303 305 308 310 311 314 319 321 323 327
327 327 333 334 338 341 342 344
Xii
CONTENTS
Model 3: Growing Annuities Model 4: Loan Amortization Table, Version 1 Model 5: Loan Amortization Table, Version 2 Model 6: Loan Amortization Table for Changing Interest Rate Model 7: Loan Amortization Table for Changing Annual Payment Model 8: The Condominium Project
CHAPTER 15 Hnancial Planning and Investments Review of Theory and Concepts Some Basic Issues Saving and Investing for Retirement Structuring Portfolios Modeling Examples Model 1: Return with Changing Reinvestment Rates Model 2: Saving for Retirement Model 3: Retirement Planning in Real Dollars Model 4: Retirement Planning in Nominal Dollars Model 5: Portfolio Structuring
CHAPTER 16 Analyzing Market History Review of Theory and Concepts Indexes Measuring Returns Risk Modeling Examples Model 1: Calculating Total Returns Model 2: Comparing Returns on Several Assets Model 3: Comparing Nominal and Real Growth of Investment Model 4: Comparing Rolling Period Returns
CHAPTER 17 Bond Pricing and Duration Review of Theory and Concepts Key Characteristics of Bonds Bond Valuation Risks of Bond Investing Bond Duration The Yield Curve and Forward Rates
348 351 354 356 359 361
305 365 365 368 371 372 372 376 379 380 385
389 389 389 390 394 394 394 397 400 402
409 409 409 411 413 414 415
Contents
Xiii
Modeling Examples Model 1: Yield Curve and Forward Rates Model 2: Bond Pricing Using Yield to Maturity Model 3: Bond Pricing Using the Yield Curve Model 4: Bond Duration and Its Dependence on Yield to Maturity Model 5: Dependence of Bond Duration on Remaining Life
CHAPTER 18 Simulating Stock Prices Review of Theory and Concepts Generating Random Numbers Modeling Examples Model 1: Estimating a Stock's Volatility, Version 1 Model 2: Estimating a Stock's Volatility, Version 2 Model 3: Simulating Stock Prices Model 4: Lognormal Distribution of Stock Prices
CHAPTER 19 Options and Option Portfolios Review of Theory and Concepts Option Basics and Terminology Payoffs of Options at Expiration The Black-Scholes-Merton Equation for Option Valuation The Greek Letters Valuing American Options Option on Other Assets Option Portfolios Modeling Examples Model 1: Option Payoffs at Expiration Model 2: Profit of Option Portfolios at Expiration Model 3: Profit of Option Portfolios at Expiration (Using Array Formulas) Model 4: BSM Model and the Greek Letters Model 5: Variation of Option Price with Stock Price Model 6: Variation of Option Price with Volatility Model 7: Variation of Delta with Time to Expiration Model 8: Leverage of Options Model 9: Profit of Options Portfolio at Any Time
fc.
416 416 418 420 422 424
427 427 437 438 438 440 442 445
449 449 449 451 452 455 458 459 459 460 460 462 466 469 472 476 478 481 483
xiv
CONTENTS
CHAPTER 20 Binomial Option Pricing
Review of Theory and Concepts Modeling Examples Model 1: European Options on Stocks with Known Dividend Yield Model 2: American Options on Stocks Paying No Dividend Model 3: American Options on Stocks with Known Dividend Yields Model 4: American Options on Stocks with Known Dollar Dividends
487 487 491 491 495 498 500
Part Three VBA for Financial Modeling CHAPTER 21 Introduction to VBA
Why Learn VBA? Understanding Programs Example of a VBA Model Running the Model Analyzing the Model The Order of Statements Recording Macros Using VBA's Help Finding Help in Excel 2007 Finding Help in Previous Versions of Excel The Strategy to Learn VBA Efficiently CHAPTER 22 VBA Essentials
The Visual Basic Editor The VBE Window Using the Project Explorer Window Using the Code Window Setting VBE Options Some Basics Entering Code Running Procedures Organizing Procedures in Modules Line Continuation Multiple Statements in One Line Adding Comments Indenting Code Lines
505 506 509 510 511 512 519 520 524 524 524 526
529 530 531 532 534 534 535 535 536 537 537 538 538 539
Contents
XV
Operators Working with Text The MsgBox Function The InputBox Function The Stop and End Statements Variables, Constants, and Arrays Naming Variables Changing Variable Names Data Types ! Declaring Variables ' Scope of Variables Constants Arrays Objects, Properties, and Methods Objects Properties Methods Branching If Statements Select Case... End Select Statement GoTo Statement Looping For... Next Statement Do... Loop Statements Nested Loops For Each... Next Statement The Exit Statements With... End With Statement Using Built-in Functions
CHAPTER 23 Sub and Function Procedures Sub Procedures The Structure of Sub Procedures Using Sub Procedures Function Procedures The Advantages of Function Procedures The Structure of Function Procedures Using Function Procedures CHAPTER 2 4 Debugging VBA Codes
The Four Basic Types of Bugs The VBA Debugging Tools
540 541 542 544 545 545 546 547 547 549 550 553 553 557 558 560 560 561 561 565 566 567 567 569 571 572 573 573 574
577 577 577 578 582 582 583 584 589
590 591
CONTENTS
XVI
Part Four Financial Moddiig Using ¥BA CHAPTER 25 How to Build Oood VBA Models
Attributes of Good VBA Models Documenting VBA Models Learning Modeling Using VBA Sketching the VBA Code The Three Learning Tracks CHAPTER 26 Time Vaiue of Mmney Review of Theory and Concepts Solving Problems by Iteration Modeling Examples Model 1: Loan Amortization Table, Version 1 Model 2: Loan Amortization Table, Version 2 Model 3: Loan Amortization Table, Version 3 Model 4: Loan Amortization Table, Version 4 Model 5: Loan Amortization Table Using Goal Seek Model 6: Loan Amortization Table Using Arrays Model 7: MyPmt Function Model 8: Loan Amortization Table Using the Bisection Method Model 9: Loan Amortization Table for Changing Interest Rate Model 10: Loan Amortization Table for Changing Annual Payment
597 597 601 603 603 604
607 607 607 611 612 619 626 630 634 638 643 646 653 658
CHAPTER 27 Financial Planning and investments
Modeling Examples Model 1: Saving for Retirement, Version 1 Model 2: Saving for Retirement, Version 2 Model 3: Retirement Planning in Nominal Dollars, Version 1 Model 4: Retirement Planning in Nominal Dollars, Version 2 Model 5: Portfolio Structuring CHAPTER 28 Analyzing Market History
Modeling Examples Model 1: Nominal and Real Growth of $1 Investment in Stocks
663 663 666 668 674 680 691
691 691
Contents
XVII
Model 2: Growth of $1 Investment in Different Assets Model 3: Comparing Rolling Period Returns CHAPTER 29 Simulating Stock Prices
717
Modeling Examples Model 1: Estimating a Stock's Volatility Model 2: Simulating Stock Prices
717 717 719
725
CHAPTER 30 Options and Option Portfolios
CHAPTER 31
700 706
Modeling Examples Model 1: Profit of Options Portfolio at Expiration Model 2: Option Pricing Using the BSM Equations Model 3: Implied Volatility of Options Model 4: Profit of Options Portfolio at Any Time
725 725 730 734 736
Binomial Option Pricing
741 741
Modeling Examples Model 1: European Options Known Dividend Yield Model 2: American Options No Dividend Model 3: American Options Known Dividend Yields Model 4: American Options Known Dollar Dividends
on Stocks with 741 on Stocks Paying 745 on Stocks with 748 on Stocks with 750
APPENDIX A Keyboard Shortcuts for Excel
755
APPENDIX B VBA Quick Reference
757
APPENDIX C Excel and VBA Built-in Functions
759
About the CD-ROM
777
Index
781