33
4 - 1 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant University S.G. Powell K.R. Baker © John Wiley and Sons, Inc.

4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

Embed Size (px)

Citation preview

Page 1: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 14 - 1

Chapter 4: Advanced Excel Skills

Management Science: The Art of Modeling with Spreadsheets, 2e

PowerPoint Slides Prepared By:Alan Olinsky Bryant University

S.G. Powell

K.R. Baker

© John Wiley and Sons, Inc.

Page 2: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 2

Chapter Coverage

Keyboard shortcuts Controls Cell comments Naming cells and ranges Advanced formulas and functions Recording macros and using Visual Basic for

Applications

Page 3: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 3

Useful Keyboard Shortcuts: Moving, Scrolling and Entering Data

For moving and scrolling Ctrl + arrow key Move to the edge of the current data region Home Move to the beginning of the row Ctrl + Home Move to the beginning of the worksheet (A1) Ctrl + End Move to the bottom-right corner of the used area of the

worksheet PgDn Move down one screen PgUp Move up one screen Alt + PgDn Move one screen to the right Alt + PgUp Move one screen to the left F5 Display the Go To dialog box For entering data on a worksheet Alt + Enter Start a new line in the same cell Shift + Enter Complete a cell entry and move up one cell Tab Complete a cell entry and move to the right cell Shift + Tab Complete a cell entry and move to the left cell Ctrl + Delete Delete text to the end of the line Shift + F2 Edit a cell comment Ctrl + D Fill down (a selected column of cells with the content of the

first cell) Ctrl + R Fill to the right (a selected row of cells with the content of the

first cell) Ctrl + F3 Open the Define Name dialog box

Page 4: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 4

Useful Keyboard Shortcuts: Working in Cells or the Formula Bar

For working in cells or the formula bar Ctrl + Shift + Enter Enter a formula as an array formula F2 Edit the active cell F3 Open the Past Name dialog box Shift + F3 Paste a function into a formula F9 Calculate all sheets in all open workbooks Ctrl + Alt + F9 Calculate all worksheets in the active workbook Shift + F9 Calculate the active worksheet Ctrl + ;(semicolon) Enter the current date Ctrl + Shift + :(colon) Enter the current time Ctrl+ ‘(single left quote) Alternate between displaying cell values and formulas

Page 5: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 5

Useful Keyboard Shortcuts:Inserting, Deleting, Copying, Selecting

For inserting, deleting, and copying selection Ctrl + C Copy the selection Ctrl + X Cut the selection Ctrl + V Paste the selection Delete Clear the contents of the selection Ctrl + - (hyphen) Delete the selection (and move other cells to fill the void) Ctrl + Z Undo the last action Ctrl + Shift + Plus sign Insert blank cells For selecting cells, columns, or rows Shift + arrow key Extend the selection by one cell Ctrl + Shift + arrow key Extend the selection to the last nonblank cell in the same

column or row Ctrl + space bar Select the entire column Ctrl + A Select the entire worksheet

Page 6: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 6

Useful Keyboard Shortcuts:Working with Worksheets and Macros

For working with worksheets and macros Shift + F11 Insert a new worksheet Alt + F8 Display the Macro dialog box Alt + F11 Display the Visual Basic Editor (VBE) Ctrl + PgDn Move to the next sheet in the workbook Ctrl + PgUp Move to the previous sheet in the workbook Miscellaneous Ctrl + S Save an active workbook Ctrl + N Open new workbook Ctrl + O Open an existing workbook Shift + F5 or Ctrl + F Display the Find dialog box Ctrl + H Display the Replace dialog box Note: In most cases, these shortcuts are not case sensitive (that is, both “s” and “S” will work the same). Source: Sengupta, C. 2004. Financial Modeling Using Excel and VBA. Hoboken, N.J.: John Wiley.

Page 7: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 7

Controls

Excel controls allow the user to change the contents or behavior of a spreadsheet without interacting directly with individual cells.

Controls can be added to a spreadsheet to assist users to choose parameter inputs and to assist the analyst in performing sensitivity analysis.

Page 8: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 8

Standard Controls

The eleven standard controls are: Check Box Text Box Command Button Option Button List Box Combo Box Toggle Button Spin Button Scroll Bar Label Image

Page 9: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 9

Excel Tip:Using Controls

1. Place the Control toolbar on the screen (View►Toolbars►Control Toolbox).

2. Click on Design Mode. 3. Click on the desired control icon to select it. 4. Double click on the desired location in the spreadsheet to

place the control icon there. 5. Click on Properties in the Control Toolbox to open the

Properties window. 6. Edit Properties as needed. 7. Click on Exit Design Mode.

Page 10: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 10

Use of Controls

Page 11: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 11

Cell Comments

To insert a comment in a particular cell, highlight the cell and choose Insert►Comment.

Edit the comment by placing the cursor anywhere within the comment box.

To delete a comment, click on the border to highlight the comment and choose Delete.

All of the comments in a workbook can be displayed by choosing View►Comments.

When a cell containing a comment is copied, the contents and the comment are both copied to the new cell.

Page 12: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 12

Cell Comments (continued)

Page 13: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 13

Naming Cells and Ranges

Individual cells and ranges of cells can be given names, and these names can be used in formulas to make them more readable.

The simplest way to define a range name for a single cell is to place the cursor on that cell and note that the address of the cell appears in the Name box above column A.

Click in the Name box and enter the name of the cell there.

An alternative means for entering range names is to choose Insert►Name►Define.

Page 14: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 14

Define Name Window

Page 15: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 15

Documenting Range names using Paste List

Page 16: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 16

Advantages and Disadvantages of Range Names

Advantages: Formulas are easier to understand Useful in Pivot Table and other applications

Disadvantages: Range names may reference incorrect cells or ranges Adds complexity to spreadsheet Requires additional effort Complicates copying

Page 17: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 17

Advanced Formulas and Functions

Some of the tools of advanced formulas and functions: R1C1 references Mixed addresses Nesting calculations Parameterization Advanced functions

Page 18: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 18

R1C1 Style

Excel allows us to switch back and forth between the normal style and the R1C1 style of referencing.

Some modelers use the R1C1 style when developing their models but switch to the normal style when the model is complete.

They enjoy the benefits of the more logical and more easily debugged R1C1 style without imposing this less-well known style on users.

Page 19: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 19

Mixed Addresses

Using mixed addresses in copying

Page 20: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 20

Nesting Calculations

Excel allows functions to be used within other functions. This is referred to as nesting. So, for example, we could nest a SUM function within an IF function:

IF(SUM(A1:A10)>0, F9*F10, G9*G10 In fact, we can nest functions as many times as we like (in most cases),

as long as the resulting calculations can be performed by the functions themselves.

For example, we can nest IF functions within IF functions (although there is a limit of seven IFs in one formula), as in:

IF(D2>D3, G7, IF(B2>B3,G8,G9)) Or we can nest several different functions:

MIN(MAX(D4:D10), SUM(E4:E10), MIN(F4:F10))

Page 21: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 21

Parameterization

A well-parameterized function is one which represents the relationship between two or more variables accurately, with parameters that have a natural meaning in the problem being modeled.

Picking the best parameterization for the problem at hand is part of the art of modeling.

For example, a demand relationship between the price of a product and the quantity demanded could be modeled using the constant-elasticity function:Q = aPbIn this function, the parameter b measures the percentage change in quantity that results from a percentage change in price.

Page 22: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 22

Example of Parameterization

A flexible four-parameter function for market share growth.

Page 23: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 23

Advanced Functions

AND and OR SUMIF and COUNTIF VLOOKUP and HLOOKUP INDEX, SMALL and MATCH Text and date functions ROUND, CEILING, FLOOR, and INT RAND and RANDBETWEEN Financial functions

Page 24: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 24

Using Nested Functions

Page 25: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 25

Recording Macros and Using VBA*

Macros are small computer programs that automate frequently-performed tasks.

Macros are written in the Visual Basic for Applications (VBA) language and stored in Visual Basic modules.

Excel provides a mechanism for creating macros simply by recording the steps involved, so many simple macros can be created by users who have little or no programming knowledge.

Page 26: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 26

Calculating Cumulative Returns using Excel

Page 27: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 27

Record Macro Window

Page 28: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 28

Visual Basic Editor

Page 29: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 29

Cumulative Return Macro as Recorded

Sub Cumulative_return()' Macro recorded 2/27/2006 by The Tuck School Columns("C:D").Select Selection.Insert shift:=xlToRight Range("C4").Select ActiveCell.FormulaR1C1 = "=RC[-1]+1" Range("C4").Select Selection.Copy Range("C5:C25").Select ActiveSheet.Paste Range("D4").Select Application.CutCopyMode = False Range("D4").Select ActiveCell.FormulaR1C1 = "=PRODUCT(R4C3:RC[-1])-1" Range("D4").Select Selection.AutoFill Destination:=Range("D4:D25"), Type:=xlFillDefault Range("D4:D25").SelectEnd Sub

Page 30: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 30

Cumulative Return Macro as Edited

Sub CumulativeEdited()'declare ranges for the user's data, the return + 1, and the cumulative return Dim userdata As Range, plusOneRng As Range, cumRetRng As Range Set userdata = Selection 'insert two new columns ActiveSheet.Columns(userdata.Column + 1).Select Selection.Insert shift:=xlToLeft Selection.Insert shift:=xlToLeft 'select where the new data is going to be added Set plusOneRng = userdata.Cells(1).Offset(0, 1) Set cumRetRng = userdata.Cells(1).Offset(0, 2) 'create a column with the returns + 1 plusOneRng.Select ActiveCell.FormulaR1C1 = "=RC[-1]+1" plusOneRng.Select Selection.Copy userdata.Offset(0, 1).Select ActiveSheet.Paste 'create a column with the cumulative returns cumRetRng.Select ActiveCell.FormulaR1C1 = _ "=PRODUCT(R" & cumRetRng.row & "C" & cumRetRng.Column - 1 & ":RC[-1])-1" cumRetRng.Select Selection.AutoFill Destination:=Range(userdata.Offset(0, 2).Address), _ Type:=xlFillDefaultEnd Sub

Page 31: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 31

User-defined Function to Calculate Cumulative Return

Public Function CumulativeReturn (Returns As Range) Dim cell As Range Dim TotalRet As Double TotalRet = 1# For Each cell In Returns.Cells TotalRet = TotalRet * (cell.Value + 1#) Next CumulativeReturn = TotalRet - 1#End Function

Page 32: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 32

Summary

Keyboard shortcuts Controls Cell comments Naming cells and ranges Advanced formulas and functions Recording macros and using Visual Basic for

Applications

Page 33: 4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant

4 - 33

Copyright 2008 John Wiley & Sons, Inc.

All rights reserved. Reproduction or translation of this work beyond that permitted in section 117 of the 1976 United States Copyright Act without express permission of the copyright owner is unlawful. Request for further information should be addressed to the Permissions Department, John Wiley & Sons, Inc. The purchaser may make back-up copies for his/her own use only and not for distribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages caused by the use of these programs or from the use of the information herein.