Presentation on theme: "4 - 1 Chapter 4: Advanced Excel Skills Management Science: The Art of Modeling with Spreadsheets, 2e PowerPoint Slides Prepared By: Alan Olinsky Bryant."— Presentation transcript:
4 - 6 Useful Keyboard Shortcuts: Working with Worksheets and Macros
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.
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
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.
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.
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.
4 - 15 Documenting Range names using Paste List
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
4 - 17 Advanced Formulas and Functions Some of the tools of advanced formulas and functions: R1C1 references Mixed addresses Nesting calculations Parameterization Advanced functions
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.
4 - 19 Mixed Addresses Using mixed addresses in copying
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))
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 = aPb In this function, the parameter b measures the percentage change in quantity that results from a percentage change in price.
4 - 22 Example of Parameterization A flexible four-parameter function for market share growth.
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
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.
4 - 26 Calculating Cumulative Returns using Excel
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").Select End Sub
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 '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:=xlFillDefault End Sub
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
4 - 32 Summary Keyboard shortcuts Controls Cell comments Naming cells and ranges Advanced formulas and functions Recording macros and using Visual Basic for Applications
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.