Tips & Tricks for Excel-Based Financial Modeling Tips & Tricks for Excel-Based Financial Modeling A Must for Engineers & Financial Analysts Volume I M A Mian, PE Tips & Tricks for Excel-Based Financial Modeling: A Must for Engineers & Financial Analysts, Volume I Copyright © Business Expert Press, LLC, 2017 All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means—electronic, mechanical, photocopy, recording, or any other except for brief quotations, not to exceed 400 words, without the prior permission of the publisher First published in 2017 by Business Expert Press, LLC 222 East 46th Street, New York, NY 10017 www.businessexpertpress.com ISBN-13: 978-1-63157-946-2 (paperback) ISBN-13: 978-1-63157-947-9 (e-book) Business Expert Press Finance and Financial Management Collection Collection ISSN: 2331-0049 (print) Collection ISSN: 2331-0057 (electronic) Cover and interior design by Exeter Premedia Services Private Ltd., Chennai, India First edition: 2017 10 Printed in the United States of America Abstract The purpose of this work is to show some advanced concepts related to Excel based financial modeling Microsoft ExcelTM is a very powerful tool and most of the time we not utilize its full potential Although not very difficult to use but it needs practice and continuously striving to use the full potential of Excel Of course, any advanced concepts require the basic knowledge which most of us have and then build on it It is only by hands-on experimentation that one learns the art of constructing an efficient worksheet It is hoped that the examples herein will aid the reader to develop his or her own worksheets using advanced concepts The biggest advantage of Excel is that it is not a black box, especially if you have built the model yourself rather than working with somebody else’s model The basic requirement for most financial modeling is to keep them simple so anyone can look at it can easily figure out how most of the calculations are performed The two volumes of this book cover dynamic charting, macros, goal seek, solver, the routine Excel functions commonly used, the lesser known Excel functions, the Excel’s financial functions, and so on The introduction of macros in these books is not exhaustive but the purpose of what is presented is to show you the power of Excel, and it can be utilized to automate most repetitive calculations at a click of a button For those who use Excel on a daily basis in financial modeling and project/investment evaluations, this book is a must It contains a wealth of practical examples, tips, new techniques all designed to help quickly exploit and master Excel to its full advantage and therefore use spreadsheets more effectively in your jobs Keywords advance Excel, Excel based financial modeling, financial modeling, investment evaluation, investment evaluation modeling, Microsoft ExcelTM, project economics Contents Preface Chapter 1Introduction Chapter 2Overview of Project Economics Chapter 3Excel’s Financial Functions Chapter 4Most Used Excel Functions Chapter 5Data Management Chapter 6Evaluating Data About the Author Index Preface This book is an outcome of teaching “Project Economics, Risk and Decision Analysis” course to more than 800 participants since 2006 The course is computer based where problems are solved using Excel It is observed during these courses that a majority of the participants really struggle with the correct and efficient use of Excel in solving problems The book is about utilizing full potential of Microsoft Excel in financial modeling and other technical fields Simple, intuitive, step-by-step instructions reinforce theoretical intuition while teaching mechanics of the model building process The author uses his 35 years of experience in writing this book and therefore it introduces the most practical and direct approach to mastering the Excel-based financial modeling The book teaches students and professionals how to build, analyze, interpret, and present financial models in a step-by-step fashion at their own pace A case study format is used to make sure the recipients can comprehend the real life modeling challenges The book bridges the gap between academics and the real world to equip recipients with the practical financial skill set that they will need on the job The book starts with introducing the basic financial and other routinely usable functions of Excel, how to correctly use these functions, what are the limitations of these functions, how to overcome these limitations, and so on The book then grills into how to incorporate these functions into the context of a complete economics or financial model Finally, it provides opportunity to help users interpret the outcome of the models The book will not only help in exploring the most advanced features of Excel, it will also help you in understanding the financial analysis concepts, project economics models, fiscal regimes in the oil and gas industry, crafting the most dynamic fiscal models, dynamic charting, sensitivity analysis, building waterfall charts, building multi-variable cross plots, and spreadsheet automation through macros and VBA Who is the audience for this book and why they should not be without it? Financial analysts Engineers involved in budgeting, AFE preparation, and project economics (engineering economics) Personnel involved in preparation of Corporate Business Plan New Business Development personnel Professionals related to Investment, Equity Research, Credit, Project, Mergers and Acquisition, and Corporate Finance Students pursuing financial and engineering education (undergraduate and graduate) at the university level The in-depth knowledge of Excel will greatly enhance their efficiency and out of the box thinking It is also emphasized in the class that it is always helpful to draw a time diagram to be able to visualize where the cash out-flows and in-flows are taking place The most common mistake in project economics is when the economists fail to properly identify the timing of the cash-flows Although it may look trivial, shifting a cash-flow by one period can make significant difference in decision making Besides this book, specific to financial modeling, there are many, many other sources available to learn from They are all good references but they provide generic use of Excel, that is, not specific to financial modeling It takes time to understand these generic applications and then try to incorporate them in the financial modeling I have concentrated on the use of some of the ones I frequently visit or consult with, as shown below: I frequently use Excel Forum (www.excelforum.com) when I am stuck I have always received prompt and valuable suggestions from the members of Excel Forum From time to time I log into Chandoo’s blog (http://chandoo.org/wp) to capture new ideas The Peltier Tech Blog (http://peltiertech.com) is another useful blog with good tips and tricks from time to time My Online Training Hub by Mynda Treacy (www.MyOnlineTrainingHub.com) I have also subscribed to the Excel Demy’s (www.ExcelDemy.com) periodic e-mails with useful tips and tricks However, a majority of the sites give generic examples and some of them may not be even applicable to specific financial modeling situations The thing that is different with this book is that it is specific to financial modeling and bridges the gap between the generic and specific techniques The concepts presented in this book are accompanied by Excel spreadsheets and worksheets so that the users can reinforce their understanding by looking at how these are developed These spreadsheets are available in a Dropbox at the following link For any questions, corrections, and suggestions please feel free to contact the author at mianma@OGKnowledgeShare.com or mianma.OGKnowledgeShare@gmail.com All the figures and tables in this book are available at the following link on DropBox https://www.dropbox.com/sh/k3m504hyibuy1gq/AACE4msYC-2JYd8WyaP_K534a?dl=0 CHAPTER Introduction Historical Perspective I am not a historian but I have seen some mind boggling inventions and changes in the way we had been performing our data manipulation and calculations in my lifetime This is a very interesting anecdote to remember since my childhood 1965: My father was a cashier in a bank I used to see big (24inch × 24-inch × 4-inch thick) books called ledgers Each page of these ledgers used to have several columns and rows Each book covered debits and credits for certain accounts These ledgers were used to account for all the daily bank transactions of debit and credits Sometimes my father used to come very late from the office and when asked for the reason, my father would say “the ledger was not balancing—there was a difference of so many cents” (sometimes ridiculously small amount) We used to tell him “Dad you should have just put this small amount of money from your pocket into the account.” He would laugh These ledgers are now replaced by electronic ledgers 1971 to 1975: I was in engineering college We used to use an instrument called Slide Rule and Log Books to perform all our calculations The world’s first handheld and pocket calculator was introduced by HP on February 1, 1972 and by Texas Instruments (TI) on January 15, 1974 I was in my final year of Engineering in 1975 when I got my first calculator I was the only student in the university with a scientific calculator but I was not allowed to use it in my final year engineering examination Apparently, the invigilators thought that the calculator will help me in answering the questions correctly or they did not want me to have a competitive edge over the other students In 1975, the first programmable calculator (SR-52 by TI) with nonvolatile magnetic card storage was introduced in the market W e used to have some of these in the early eighties with petroleum engineering problems on cards 1978 to 1980: I was doing my masters in Colorado School of Mines, Golden, Colorado, US Even at that time we did not have lookup_value—the value to search in the first column of the table or range The lookup_value argument can be a value or a reference If the supplied value for the lookup_value argument is smaller than the smallest value in the first column of the table_array argument, VLOOKUP will return the #N/A error value table_array—the range of cells that contains the data You can use a reference to a range (for example, A3:K12 in Figure 2.26), or a range name The values in the first column of table_array are the values searched by lookup_value These values can be text, numbers, or logical values Uppercase and lowercase texts are equivalent col_index_num—the column number in the table_array argument from which the matching value must be returned A col_index_num argument of returns the value in the first column in table_array; a col_index_num of returns the value in the second column in table_array, and so on a If the col_index_num argument is less than 1, VLOOKUP returns the #VALUE! error b If the col_index_num is greater than the number of columns in table_array, VLOOKUP returns the #REF! error range_lookup—a logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match, it can be either TRUE or FALSE If it is TRUE, or if it is omitted, VLOOKUP will assume that our input table_array is sorted in ascending order, and will find the nearest table value that is still less than the lookup_value specified If range_lookup is set to FALSE, VLOOKUP will only return an exact match with the specified lookup term VLOOKUP is a great tool for pulling data from tables, but it has some limitations It can only work with one criteria for matching information If there are multiple rows in a sheet with the same information, only the first one will be retrieved We can combine the VLOOKUP with INDEX and MATCH functions to surpass some of the limitations Figure 6.22 shows the use of VLOOKUP function The following formula is entered in Cell B14 Note that column number is static and if we insert another column or delete a column in the table it will become a mess =VLOOKUP(A14,A3:K12,4,FALSE) It is asking Excel to find the price of crude in year 2023 (given in Cell A14) by looking into the entire table of prices from Cell A3 to Cell K12 and column four (high price scenario) and we need an exact match, that is, range_lookup is FALSE Excel returns crude price of $67.94 in Cell B14 Figure 6.22 Use of Excel’s VLOOKUP function Combining VLOOKUP and MATCH Functions The above mentioned limitation of specifying the column number (col_ index_num) can be overcome by combining the VLOOKUP function with the MATCH function This combination provides better control over how the column index number changes This is often referred to as a dynamic formula Here we learn how this can help prevent errors and improve your VLOOKUP formulas by making it more dynamic This is achieved by replacing the static column number (number 4) in the VLOOKUP formula by a MATCH function as shown in Figure 6.23 Note that this formula has to be again entered as an array formula by pressing CTRL+SHIFT+ENTER simultaneously The result in Figure 6.23 is the same as in Figure 6.22 but the combined use of VLOOKUP and MATCH makes it more dynamic and adding or deleting columns will not affect the result Figure 6.23 Use of combined VLOOKUP and MATCH functions The HLOOKUP Function The HLOOKUP function is similar to the VLOOKUP function The only difference is that VLOOKUP searches in a specified Column (col_indes_num) while the HLOOKUP searches in a specified Row (row_ index_num) Both have the same limitations, that is, the VLOOKUP will not lookup the right value if the reference Column is changed by adding or deleting Columns in the table array and the HLOOKUP will not lookup the right value if the reference Row is changed by adding or deleting Rows in the table array Given below are the syntax for both VLOOKUP and HLOOKUP for comparison =VLOOKUP(lookup_value, table_array, col_index_num, range_ lookup) HLOOKUP(lookup_value, table_array, row_index_num, [range_ lookup]) Figure 6.24 shows the use of HLOOKUP function in Cell C4 and the result in Cell E10 The following formula is used in Cell C4, in which the lookup_value is 2023 in Cell C3, the table_array is in Cells C7:L17, the row_indes_num is and range_lookup is FALSE (i.e., exact match is required) It is not accounting for the product type in Cell C1 and pricing scenario in Cell C2 =HLOOKUP(C3,C7:L17,4,FALSE) Figure 6.24 Use of HLOOKUP and combined HLOOKUP and MATCH functions As in the case of VLOOKUP, the above limitation can be overcome by combining the HLOOKUP and MATCH functions and enter them as an array formula in Cell C5 by pressing CTRL+SHIFT+ENTER The array formula in Cell C5 is shown below ={HLOOKUP(C3,C7:L17,MATCH(C1&C2,A7:A17&B7:B17,0),FALSE)} The IFS Function The Excel 2016 introduces a new function that can be used instead of nested Ifs—the IFS function The IFS function provides a special structure for evaluating multiple conditions without nesting The syntax of the IFS formula is: =IFS(test1, result1, [test2, result2], ) Accordingly, the formula in Cell C5 (Figure 6.7) can be replaced by: =IFS(B5=E$1,”D”,B5>=D$1,”C”,B5>=C$1,”B”,B5>=B$1,”A”) The CHOOSE Function CHOOSE can handle up to 254 values Index_num returns a value based on its position in the list The CHOOSE function is a built-in function in Excel that is categorized as a Lookup/Reference Function, similar to the VLOOKUP, HLOOKUP and so on, the CHOOSE function can be entered as part of a formula in a cell of a worksheet The syntax of the IFS formula is: =CHOOSE (index_num, value1, [value2], ) The arguments of the function are: index_num—The value to choose A number between and 254 a If index_num is 1, CHOOSE returns value1; if it is 2, CHOOSE returns value2; and so on b If index_num is less than or greater than the number of the last value in the list, CHOOSE returns the #VALUE! error c If index_num is a fraction, it is truncated to the lowest integer before being used value1—The first value from which to choose value2—[optional] The second value from which to choose a Values can also be references For example, the address A1, or the ranges A1:10 or B2:B15 can be supplied as values b The CHOOSE function can be embedded into another function as shown below =SUM(CHOOSE(2,A1:A10,B1:B10,C1:C10)) The CHOOSE function is evaluated first, returning the reference B1:B10 The SUM function is then evaluated using B1:B10, the result of the CHOOSE function, as its argument Figure 6.25 shows how the CHOOSE function can be used in financial modeling Figure 6.25 shows three pricing scenarios (a) scenario in Cells C3:H5, (b) scenario in Cells C7:H9 and (c) scenario in Cells C11:H13 Cell B15 allows the user to select the desired pricing scenario to be used in economic evaluation Different profitability indicators can be obtained by just changing the scenario in Cell B15 The formula =CHOOSE($B$15,C3,C7,C11) is entered in Cell C16 and then dragged to C18 The C16:C18 is then dragged to Column H (Cells H16:H18) Figure 6.25 Use of CHOOSE function to pick pricing scenario The Excel CHOOSE function can also return cell references The reference that is returned from the CHOOSE function is then provided other Excel functions such as SUM, AVERAGE and so on This is accomplished by entering =AVERAGE(CHOOSE(B15,C3:C5,C7:C9,C11:C13)) in Cell B20 where the average price per year is calculated based on the scenario selected The IFERROR Function The IFERROR function is used to trap and handle errors produced by other formulas or functions IFERROR checks for the following errors: #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, or #NULL! You can use the IFERROR to catch the error and then replace it by another custom value/parameter such as zero (0) or N/A or blank Cell “” The syntax of the IFERROR formula is: =IFERROR (value, value_if_error) The arguments of the function are: Value—The value, reference, or formula to check for an error value_if_error—The value to return if an error is found Figure 6.26 shows calculation of IRR for the cash flow in Cells B2:F2 The Excel function =IRR(B2:F2) is entered in Cell B3 The IRR is giving #NUM! error We can hide this error message by using the IFERROR function as shown in Figure 6.27 Similarly, if we are calculating a running IRR in Cells B5:F5 This gives #NUM! error in the beginning years, negative IRR in 2019 and 2020 and then finally turning into a positive IRR The running IRRs are required in some financial or economic models Figure 6.26 The IRR function giving #NUM! error Figure 6.27 Using the IFERROR function to hide error By replacing the =IRR(B2:F2) in Cell B3 by =IFERROR(IRR(B2:F2),”N/A”) will enter N/A in Cell B3 when there is error This will show that the IRR for this cash flow cannot be calculated because the negative cash flows are higher than the positive cash flows and there is no rate of return This is shown in Figure 6.27 Instead of “N/A” we can also use zero so the cell will show zero when there is error The ISERROR Function We can also fix the running IRR in Cells B5:F5 by entering a combination of IF and ISERROR functions in Cell B5 and then copying them to F5 The Microsoft Excel ISERROR function can be used to check for error values such #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME? or #NULL The syntax for the ISERROR function is: ISERROR(value) The arguments of the function are: Value—this is the value to be tested If the value is an error then the ISERROR function will return TRUE otherwise it will return FALSE The difference between IFERROR and ISERROR In the IFERROR function, the value is entered only once, that is, if the value is error then it will enter user specified value else it will enter the calculated value such as =IFERROR(IRR(B2:F2),”N/A”) Using ISERROR with the same problem as in Cell B3 of Figure 6.26, we enter the logic as =IF(ISERROR(IRR(B2:F2)),”N/A”,IRR(B2:F2)) You can see that the IRR(value value) is entered twice here instead of once in the IFERROR function On the other hand, IFERROR will not work with multiple logics For example, in Cells B5:F5 of Figure 6.27 we want the logic to enter “N/A” or “0” or “” if there is error or if the value is negative Otherwise enter the value Figure 6.28 shows the use of IF and ISERROR in Cells B5:F5 The formula =IF(ISERROR(IRR($B4:B4)),0,IF(IRR($B4:B4)