Excel is the world’s premier spreadsheet software. You can use Excel to analyze numbers, keep track of data, and graphically represent your information. With Excel 2010, you can manage more data than ever, with increased worksheet and workbook sizes. Excel also makes your job easier by providing an easy to use interface, and an array of Excel 2010 Formulas & Functions Module3 Christine M. Dandaraw, MCT The backbone of Excel is its ability to perform calculations. There are two ways to set up calculations in Excel: using formulas or using functions. Formulas are mathematical expressions that you build yourself. You need to follow proper math principles in order to obtain the expected answer. Building the formula is simply a matter of combining the proper cell addresses with the correct operators in the right order. This module will explore how to build, edit, and copy formulas. Table of Contents Create Basic Formulas ............................................................................... 3 Formula Basics:........................................................................................ 3 Operators used in Formulas: ...................................................................... 4 Calculate with Functions ............................................................................ 5 Editing Formulas ...................................................................................... 6 References in Formulas ............................................................................. 7 Quick Calculator ....................................................................................... 8 Create an Absolute Reference ..................................................................... 8 Create an Absolute Reference ..................................................................... 9 Arguments .............................................................................................. 9 Copying a Formula: Drag and Drop Method .................................................10 To fill formulas ........................................................................................10 Formula Bar ............................................................................................11 The Insert Function Dialog ........................................................................13 The Insert Function Dialog ........................................................................13 Search for a Function ...............................................................................14 Select A Category ....................................................................................14 Paste Special ..........................................................................................14 Switching Rows of Cells to Columns or Columns to Rows ...............................14 Pasting Only Values, Formulas, Comments, or Cell Formats ...........................15 The Date function ....................................................................................15 Date Functions ........................................................................................16 Date Functions ........................................................................................16 The Days360 Function in Excel ..................................................................18 Using Financial Functions ..........................................................................19 PMT Function ..........................................................................................19 Financial Formulas - by Category ...............................................................22 Depreciation Formulas ..............................................................................22 Formulas for Interest, Cash Flow, Investments, Annuities ..............................22 Functions for Coupons ..............................................................................22 Finance Formulas for Securities .................................................................23 Formulas for Dollar Price Conversions .........................................................23 Treasury Bill Functions .............................................................................23 Using Logical “IF” Function ........................................................................24 Performing calculations ............................................................................25 Displaying text ........................................................................................26 Leaving Cells Blank Diocese of St. Petersburg 26 pg. 2 9/5/2014 Create Basic Formulas Formulas are entries that have an equation that calculates the value to display. We DO NOT type in the numbers we are looking for; we type in the equation. This equation will be updated upon the change or entry of any data that is referenced in the equation. Formula Basics: Formulas OR Functions MUST BEGIN with an equal sign (=) so that Excel can distinguish it from text. We use formulas to CALCULATE a value to be displayed. A formula consists of any of the following elements: A. Mathematical operators B. Cell references (including named cells and ranges) C. Values or text D. Worksheet functions (such as SUM or AVERAGE) Examples of formulas: =100*.05 Multiplies 100 times 0.05 (This formula only uses values and therefore is not very useful) =A1*A2 Multiplies the contents of cell A1 by the contents of cell A2 (This formula uses cell references.) =Income-Expenses Subtracts the cell named Expenses from the cell named Income Diocese of St. Petersburg pg. 3 9/5/2014 Operators used in Formulas: + Addition - Subtraction * Multiplication / Division ^ Exponentiation & Concatenation = Logical comparison (equal to) > Logical comparison (greater than) < Logical comparison (less than) >= Logical comparison (greater than or equal to) <= Logical comparison (less than or equal to) <> Logical comparison (not equal to) You can use as many operators as you need in a formula. Operator Precedence in Formulas: Excel follows a certain order of operators, when it calculates a formula: 1. Items in parentheses 2. Exponentiation 3. Multiplication and division (from left to right) 4. Addition and subtraction (from left to right) Example: =(B2-B3)*B4 will yield a different result than =B2-B3*B4 Probably the most popular function in any spreadsheet is the SUM function. The Sum function takes all of the values in each of the specified cells and totals their values. The syntax is: =SUM(first value, second value, etc) There are many functions built into many spreadsheets. Diocese of St. Petersburg pg. 4 9/5/2014 Average function. The average function finds the average of the specified data. (Simplifies adding all of the indicated cells together and dividing by the total number of cells.) The syntax is as follows. =Average (first value, second value, etc.) Calculate with Functions SUM Example = SUM(C3:G9) Result: Total of all numbers in the range. AVERAGE Example = AVERAGE(C3:G9) Result: Average of all numbers in the range. COUNTIF Example = COUNTIF(C3:G9, “>55”) Result: # of cells in the range containing numbers greater than 55. COUNTA Example =COUNTA(C3:C25) Result: Number of Actual items in row Used in counting groups of similar numbers within a set of data. TODAY() Example = TODAY() Result = current date. Useful for forms that require a date. ROUND Example = ROUND(A4/3,2) Result if A4 = 5 then 5/3 = 1.6666 which is rounded to 1.67 Entering Formulas into Your Worksheet: a. Manually – just type the formula starting with the equal sign b. By pointing – type an equal sign, click on the cell, type in the operator, click on the next cell Diocese of St. Petersburg pg. 5 9/5/2014 Name Box displays the reference of the active cell Drops down a list of names The Cancel Button cancels the entry in the The Enter Button accepts the entry in the formula bar Edit Formula initiates the formula editor Entry Area of the formula bar Active Cell Editing Formulas Excel provides multiple ways to edit the contents of a cell: a. Double click on the cell b. Press F2 while the cell is active c. Click on the formula bar while the cell is active Formula Bar Diocese of St. Petersburg pg. 6 9/5/2014 References in Formulas: References identify cells or groups of cells on a worksheet. Column references range from A through IV (256 columns). Row references range from 1 through 16,384 References are of three types: Relative A10 Absolute $A$10 Mixed $A10 or A$10 Use the F4 key to convert relative references to absolute or mixed references. The F4 key cycles through each type. AutoSum AutoSum is a simple mathematical formula to display the total sum of the neighboring cells. Excel chooses these cells automatically based on the ideal usage of the position of the result. AutoSum first checks if there is any continuous group of cells which has numbers above the result cell for its range, then it checks to the left side of the result cell. But the range of cells that are included for the calculation can be reselected manually by dragging if it’s wrong. How to use AutoSum? In Excel 2003, you can use the AutoSum symbol (which is a sigma sign) from the toolbar and In Excel 2007, you can find the AutoSum function in the Editing section (which is on the far right side) under Home tab. Keyboard Shortcut to AutoSum in Excel But you can always use the keyboard Shortcut, ALT + = to do the AutoSum. This tip comes very handy if most of your daily calculations depend on addition of values. Diocese of St. Petersburg pg. 7 9/5/2014 Quick Tip: AutoSum can be used not only when the values are adjacent to the result cells, but even if it’s randomly displayed. All that you have to do is, press ALT+= in the cell where you want the result to be displayed and while holding the CTRL key click all the cells that you want to be included in the result. Quick Calculator When you want a quick calculation of a column highlight the range of cells or entire column and select the quick calculator on the status bar. You can choose from several operators. Diocese of St. Petersburg pg. 8 9/5/2014 Create an Absolute Reference Excel accepts cell references in what are called absolute and relative ranges. Absolute ranges have a $ character before either the column portion of the reference and/or the row portion of the reference. Relative ranges do not use the $ character. The $ character indicates to Excel that it should not increment the column and/or row reference as you fill a range with a formula or as you copy a range. For example A1 is a relative range, while $A$1 is an absolute range. If you enter =A1 in a cell and then fill that cell down a column, the '1' in the reference will increment in each row. Thus, the formula in row 50 would be =A50. However, if you enter =$A$1 in a cell and fill down, the range reference will remain $A$1 -- it will not increment as you fill or copy down a column. There are three absolute styles: Reference Style Meaning $A$1 $A1 A$1 Both the column and row reference is fixed. Neither will be incremented or changed during a copy or fill. Only the column reference is fixed. It will not change during a fill or copy, but the row will change. Only the row reference is fixed. It will not change during a fill or copy, but the column will change. Arguments In certain cases, you may need to use a function as one of the arguments of another function. For example, the following formula uses a nested AVERAGE function and compares the result with the value 50. Valid returns When a nested function is used as an argument, it must return the same type of value that the argument uses. For example, if the argument returns a TRUE or FALSE value, then the nested function must return a TRUE or FALSE. If it doesn't, Microsoft Excel displays a #VALUE! error value. Diocese of St. Petersburg pg. 9 9/5/2014 Nesting level limits A formula can contain up to seven levels of nested functions. When Function B is used as an argument in Function A, Function B is a second-level function. For instance, the AVERAGE function and the SUM function are both secondlevel functions because they are arguments of the IF function. A function nested within the AVERAGE function would be a third-level function, and so on. Copying a Formula: Drag and Drop Method To fill formulas 1. First, click the cell that contains the formula you want to copy. 2. Move the mouse pointer to the fill handle in the lower right corner of cell until the mouse pointer changes to a large black plus sign. 3. Then drag across to the cell where you want to drop the formula. 4. Release the mouse button, Excel fills the cell with the formula. Enter a function in Formula Pallet Select the cell where you want to insert the function. Click the Insert Menu and click the Function. Select the function you want to use and click OK. Enter the function arguments and click OK. Tips Diocese of St. Petersburg pg. 10 9/5/2014 You can adjust the size of the Formula Bar. Click and drag the rounded edge of the Name Box to adjust it horizontally. To adjust it vertically, click and drag the bottom border of the Formula Bar or click the Expand Formula Bar button at the end of the Formula Bar. You can use the Formula AutoComplete feature to help you create and edit complex formulas. Type an = (equal sign) in a cell or the Formula Bar and start typing the formula. As you do this, a list appears of functions and names that fit with the text you entered. Select an item from the list to insert it into the formula. Formula Bar Click the cell in which you want to enter the formula. 1. In the formula bar , type = (equal sign). 2. Do one of the following: To create a reference, select a cell, a range of cells, a location in another worksheet, or a location in another workbook. You can drag the border of the cell selection to move the selection, or drag the corner of the border to expand the selection. To enter a reference to a named range, press F3, select the name in the Paste name box, and click OK. 3. Press ENTER. Diocese of St. Petersburg pg. 11 9/5/2014 The following formulas contain functions. Example formula What it does =SUM(A:A) Adds all numbers in column A =AVERAGE(A1:B4) Averages all numbers in the range 1. Click the cell in which you want to enter the formula. 2. To start the formula with the function, click Insert Function formula bar on the . 3. Select the function you want to use. You can enter a question that describes what you want to do in the Search for a function box (for example, "add numbers" returns the SUM function), or browse from the categories in the Or Select a category box. 4. Enter the arguments. To enter cell references as an argument, click Collapse Dialog to temporarily hide the dialog box. Select the cells on the worksheet, then press Expand Dialog . 5. When you complete the formula, press ENTER. Diocese of St. Petersburg pg. 12 9/5/2014 The Insert Function Dialog Called the Paste Function dialog in older versions, but the Insert Function dialog in newer versions, this dialog box is used to insert or paste the selected function into the chosen cell. The big advantage to using this feature comes as you become more comfortable writing Excel formulas. Initially it is most beneficial because it can be used as a step-by-step guide for each argument in a function. What this means is, if you are going to be using a simple function such as the SUM, MIN, MAX etc. , it really serves no purpose. When writing slightly harder functions such as COUNTIF, SUMIF etc. , it can aid greatly. Let’s display the Insert Function dialog and have a superficial look at it. There are three methods we can use to show this dialog box and which one you use is purely optional. The three methods are: Going to Insert>Function Push Shift + F3 Click the Insert Function icon to the left of your Formula bar (Fx), or for older version users, click the Paste Function icon on your Standard toolbar. Once activated you will see the Insert Function dialog pop up in front of you. Depending on which version of Excel you are using, these heading names may vary slightly in this dialog box. Diocese of St. Petersburg pg. 13 9/5/2014 Search for a Function Type a brief description of what you want to do in this box, then click Go to view a list of appropriate Functions. Select A Category In this dialog box you will see the Category Names that the Functions are grouped in. Click All to see a list of All Functions displayed in the Select A Function: box in alphabetical order. Click Most Recently Used to see a list of the last 10 functions used in the Select a Function: box. Paste Special Instead of copying entire cells, you can copy specified cell contents - such as the cell format or the result of a formula, but not the formula itself - with the Paste Special command. You can also switch data from columns to rows and vice versa. Switching Rows of Cells to Columns or Columns to Rows 1. Select the cells that you want to switch. 2. Open the Edit menu and select Copy. 3. Select the upper left cell of the paste area. The paste area must be outside the copy area. 4. Open the Edit menu and select Paste Special. 5. Select the Transpose check box. 6. Click OK. Diocese of St. Petersburg pg. 14 9/5/2014 Pasting Only Values, Formulas, Comments, or Cell Formats 1. Select the cell or range of cells you want to copy. 2. Open the Edit menu and select Copy. 3. Click the cell you want to paste the information into, or click the upper left boundary of the cell range you want to paste the information into. 4. Open the Edit menu and select Paste Special. 5. Select Formula to copy only the formula of the cell. 6. Highlight Values to copy only the outcome of the formula you copied into the cell and not the formula itself. 7. Select Format to copy just the format of the cell (font, alignment, and so on). 8. Choose Comments to copy only annotations for the cell. 9. Click OK to accept the option you selected. The Date function To enter the current date into the spreadsheet use the =NOW() function 1. Select the cell in the spreadsheet where you want the date to appear. 2. Type = NOW ( ) in the cell to add the current date to the spreadsheet. 3. Press the ENTER key on the keyboard. Diocese of St. Petersburg pg. 15 9/5/2014 Date Functions To enter a date Function, do the following: 1. Click on Insert from the menu bar 2. From the drop down menu, click on Function 3. In the Function category section, click on Date & Time 4. In the Function name section, click on Date 5. Click the OK button at the bottom 6. The formula palette appears on your spreadsheet 7. Click inside the Year box and enter the year 8. Click inside the Month box and enter the number of the month (e.g. 10 for October) 9. Click inside the Day box and enter the number 15 (The 15th day - or enter another number, if you want.) 10. Click the OK button at the bottom 11. Excel enters the Date in cell. Diocese of St. Petersburg pg. 16 9/5/2014 Notice how the date Function is set out in the Formula box. It is set out as =Date(2008, 10, 15). However, in cell the date appears as 4/15. It has missed out the year completely! The reason Excel has missed the year out is because of the way cell was formatted. To change the formatting of cell, click on Format form the menu bar. From the drop down menu, click on Cells. The format dialogue box appears. Click the Number tab strip at the top. Under Category, click on Date. A list of different date types appears in the Type list. The following picture shows this: The Type section of the dialogue box is where you set how you want your date to look. At the moment, the first option is selected 3/14. Scroll down and click on March 14, 2001. Then click the OK button at the bottom. Your spreadsheet will now look like this one: Diocese of St. Petersburg pg. 17 9/5/2014 The Days360 Function in Excel The Function to use when you want to work out how many days difference there are between two dates is the Date360( ) function. So click on cell you wish to have the results appear and do the following: 1. From the menu bar, click on Insert 2. From the drop down list, click on Function 3. The Paste Function dialogue box appears 4. Under Function category, click on Date & Time 5. Under Function name, click on Days360( ) 6. Click the OK button at the bottom 7. The formula palette appears on your spreadsheet: What Excel is looking for here is two dates: a start date and an end date. Click inside the Method box and enter True (This will ensure that Excel calculates from the European date system.) Click the OK button when you're done. Your spreadsheet might look like the one below: Diocese of St. Petersburg pg. 18 9/5/2014 Make sure that your cell is formatted as a number, and set the Decimal places to zero. Your spreadsheet will then show the correct answer, like the one below: Entering dates can be fairly straightforward. But performing calculations with dates can be slightly more complex. Using Financial Functions PMT Function "Calculates the payment for a loan based on constant payments and a constant interest rate." 1. Click on Insert from the menu bar 2. From the drop down menu, click on Function 3. In the Function category section, click on Date & Time Diocese of St. Petersburg pg. 19 9/5/2014 In the Function name section, click on Choose "Financial" from the box that says "Or select a category" and choose PMT from the list below. Click OK and you will be presented with this box Now, all you have to do is fill in the boxes and Excel will give you your answer: 1. In the "Rate" box, type is the cell reference that contains your interest rate. However, the lending agency will give you the YEARLY rate and what you need is the MONTHLY rate, so, you need to put B5/12 in this box (that’s B5 divided by 12 months in a year) 2. The "Nper" box is for the number of payment periods and we have that entered in B3, so put B3 in this box. (TIP: You don’t have to type B3 in the box. If your cursor is positioned in the box, you can just click on cell B3 and Excel will put it in the box for you.) 3. The "Pv" box is for the present value, or the amount you are going to pay. That value is in B4, so put B4 in that box. Diocese of St. Petersburg pg. 20 9/5/2014 4. Notice that "Fv" and "Type" are not in bold like the others. This is because these arguments are optional, whereas the bold ones are mandatory. See at the bottom of the box that Excel tells you that Fv is the future value and if you leave it empty, Excel will assume 0 (zero). Since you want to pay this loan off entirely, you want a zero balance, so just hit your tab key to leave this empty and move to the "Type" box. 5. Lending agencies often offer different payment amounts if the load is paid at the beginning of the month than if it is paid at the end of the month. Your lending agency will tell you if they offer this. For now, put a zero (0) in that box, assuming you will pay this loan at end of the month. 6. Then click OK. Your spreadsheet should now look like this and you see your monthly payments with these choices are $436.70. And, if you want to know if you can retire early, try Excel’s Financial Function named "FV" and see if you can figure out how to determine what that savings plan you have will be worth in 25 years. Diocese of St. Petersburg pg. 21 9/5/2014 Financial Formulas - by Category Financial functions, with a * next those that are only available after installing the Analysis ToolPak (To install, go to Tools > Add-ins > and select Analysis ToolPak). Depreciation Formulas DB - Fixed-Declining Balance DDB - Double-Declining Balance SLN - Straight-Line Depreciation SYD - Sum-of-Years' Digits VDB - Variable Declining Balance * AMORLINC - (for the French accounting system) Depreciation for each accounting period * AMORDEGRC - (for the French accounting system) Uses a depreciation coefficient Formulas for Interest, Cash Flow, Investments, Annuities * CUMIPMT - Cumulative Interest Payment * CUMPRINC - Cumulative Principal * EFFECT - Effective annual interest rate FV - Future Value of an investment * FVSCHEDULE - Future Value with a variable rate IPMT - Interest Payment for an investment or loan IRR - Internal Rate of Return ISPMT - Interest Payment during a Specific period (for compatibility with Lotus) MIRR - Modified Internal Rate of Return NPER - Number of Periods for an investment or loan NPV - Net Present Value formula PMT - Periodic Payment for an annuity PPMT - Payment on the Principal for an annuity or loan PV - Present Value of an investment RATE - Interest rate per period * XIRR - Internal Rate of Return (not necessarily periodic) * XNPV - Net Present Value (not necessarily periodic) Functions for Coupons * COUPDAYBS - Days from the Beginning of the Coupon period to the Settlement date * COUPDAYS - Days in the coupon period that contains the Settlement date * COUPDAYSNC - Days from the Settlement date to the Next Coupon date * COUPNCD - Next Coupon Date after the settlement date * COUPPCD - Previous Coupon Date before the settlement date * COUPNUM - Number of coupons between the settlement and maturity date Diocese of St. Petersburg pg. 22 9/5/2014 Finance Formulas for Securities * ACCRINT - Accrued Interest * ACCRINTM - Accrued Interest at Maturity * DISC - Discount rate * DURATION - Annual Duration * INTRATE - Interest rate for a fully invested security * MDURATION - Macauley modified duration (with an assumed par value of $100) * NOMINAL - Annual nominal interest rate * ODDFPRICE - Price per $100 face value with an Odd First period * ODDFYIELD - Yield with an Odd First period * ODDLPRICE - Price per $100 face value with an Odd Last period * ODDLYIELD - Yield with an Odd Last period * PRICE - Price per $100 face value * PRICEDISC - Price per $100 face value of a Discounted security * PRICEMAT - Price per $100 face value of a security that pays interest at Maturity * RECEIVED - Amount received at maturity for a fully invested security * YIELD - Yield on a security that pays periodic interest * YIELDDISC - Annual yield for a discounted security (Treasury bill) * YIELDMAT - Annual yield of a security that pays interest at maturity Formulas for Dollar Price Conversions * DOLLARDE - Converts a dollar price from a Fraction to a Decimal number * DOLLARFR - Converts a dollar price from a Decimal number to a Fraction Treasury Bill Functions * TBILLEQ - Bond-equivalent yield for a Treasury Bill * TBILLPRICE - Price per $100 face value for a Treasury Bill * TBILLYIELD - Yield for a Treasury Bill Diocese of St. Petersburg pg. 23 9/5/2014 Using Logical “IF” Function The IF function is one of Excel’s most useful and most used functions. What it does, basically, is test to see whether a certain condition is true or false. If the condition is true, the function will do one thing, if the condition is false, the function will do something else. The basic form or syntax of the function is: =IF(logic test, value if true, value if false) The logic test is always a comparison between two values. Comparison operators are used, for example, to see if the first value is greater than or less than the second, or equal to it. The "value if true" and "value if false" parts of the function are known as arguments. They tell the function what to do, depending on the outcome of the logic test. Nested IF Functions A Nested IF function is when a second IF function is placed inside the first in order to test additional conditions. "Nesting" IF functions increases the flexibility of the function by increasing the number of possible outcomes. For example, deductions from an employee's income usually depends on employee income. The higher the income, the higher the deduction rate. We can use an IF function to determine what the deduction rate will be. For this example, if employee income is: less than $29,701, the deduction rate is 15% greater than or equal to $29,701, but less than $71,950, the deduction rate is 25% greater than or equal to $71,950, the deduction rate is 28% Diocese of St. Petersburg pg. 24 9/5/2014 The first deduction rate is handled by the logic test and the value if true argument of the first IF function. To do this, we write the beginning of the IF function as: =IF(A5 < 29701, A5*15%, To add the second and third deduction levels, we nest one IF function inside another. For example: =IF(A5<29701,A5*15%,IF(A5<71950,A5*25%,A5*28%)) The logic test of the Nested IF function, checks to see if a employee’s income is greater than or equal to $29,701, but less than $71,950. If it is, the deduction rate is 25%. If the income is greater than or equal to $71,950, the deduction rate is 28%. Additional rate changes could be added another nested IF functions inside the existing function. Note: there is no comma separator in 29,701 or 71,950 in the above example. This is because the IF function uses the comma to separate the three sections of the IF function contained within the round brackets. If you use a comma as a separator in numbers greater than a thousand, Excel will give you an error message saying you have too many arguments in your function. Performing calculations The IF function can perform different calculations depending on whether the function returns a true value or not. The example below uses different deduction rates in its calculations based on employee income. =IF(A5 < 29701, A5 * 15%, A5 * 25%) If employees earn above a certain level, one deduction rate will be used in the calculation, if their income is below this level, a different deduction rate will be used. What the above example does is test to see if the value in cell A5 is less than 29,701. If it is, the function multiplies the value in cell A5 by 15%(the "value if true" argument). If the value in A5 is greater than or equal to 29,701, then the amount in cell A5 is multiplied by 25% (the "value if false" argument). Diocese of St. Petersburg pg. 25 9/5/2014 Displaying text Having text displayed by an IF function rather than a number can make it easier to find and read specific results in the spreadsheet. Below, the example IF function is setup to test whether a student's mark is greater than or equal to 50. If it is, "Passed" is written into the target cell. If not, the word "Failed" appears. =IF(A5>=50,”Passed”,”Failed”) A second example could be used by a company to quickly determine which employees are entitled to a bonus for exceeding a certain level of production. =IF(A5>=5000,”Pay Bonus”,”No Bonus”) Leaving Cells Blank Having an IF function return a blank cell is similar to having it return words or a text statement. You use quotation marks as with text, but just don’t put anything between them. =IF(A5 > 5000,”Too High”,” ”) In this example, the IF function acts as a flag. If the value in cell A5 goes above 5,000, the warning “Too High” is displayed in the cell. If A5 is not above 5,000, there is no need for a warning so the cell remains blank. Diocese of St. Petersburg pg. 26 9/5/2014