Excel 2013 KPMG Excel Formulas and Functions Introduction This document looks at linking between Excel Sheets and Excel Workbooks, including copy/paste link, creating three dimensional formulas, and using the Data Consolidation tool. Tips for Working with Multiple Sheets 1. Group sheets together to make changes to all sheets in the group at the same time. a. Select the first sheet in the group. b. Hold the SHIFT key. c. Select the last sheet in the group. Using Copy/Paste Link to create a Summary Sheet When tracking the same type of information on different sheets (sales by region, sales by week, sales by month), it may be useful to have a summary sheet of the totals for the different sheets. If the numbers on any of the sheets were updated, it would be most efficient to have the summary sheet update automatically. One of the simplest ways to accomplish this is to use copy/paste link: 1. Select the cells to copy. 2. Copy 3. Select the cell on the summary sheet where you want to paste. 4. Right-click and select the Paste Link icon: Eastern, Northern, Central, Western are grouped. Sheet 4 is not in the group. d. Make necessary changes. NOTE: There are some things you cannot do with sheets grouped, but you can make many changes: formatting, formulas, page setup among others. e. To group non-contiguous sheets, hold the CTRL key to select sheets. f. To ungroup sheets, right-click on any sheet in the group and choose Ungroup Sheets. 2. Use Fill Across Worksheets to copy data from one sheet in a group to the same position in all the other sheets in the group. a. Group the necessary sheets. b. Highlight the information that needs to be copied to the same position in the other sheets. c. On the Home tab, select Fill > Across Worksheets 5. The formula in the cell contains the sheet name and the cell reference: 6. Do this for each sheet in the file. 7. When the totals update on any sheet, they will also update on the summary sheet. Using Copy/Paste Link to Create a Summary File If you track the same type of information in different workbooks instead of different sheets and want to create a summary workbook, you can use the same steps to link to the workbooks. 1. Go to the first workbook and select the cells to copy. 2. Copy 3. Go to the summary workbook and select the cell where you want to paste. 4. Right-click and select the Paste Link icon: In this example the total formula in row 13 would be filled into cells A13:E13 on all the grouped sheets. 5. Do this for each workbook that contains the data to summarize. 6. The formula in the cells in the summary workbook will contain the path, file name, sheet name and cell Corporate Training Group, Inc. 120 Wood Avenue S, Iselin, NJ 08830 (732)635-9033 Page 1
reference: parentheses. 7. When you open a workbook containing external links, you will get this prompt: Edit Links Click Enable Content to update the numbers from the linked files. When linking between workbooks, you may need to view, edit or break links. To view, edit or break links: 1. Open the workbook containing links (you will get the above security warning). 2. On the Data ribbon, click the Edit links button. (This button will only be available when there are external links in a workbook). Creating a Three-Dimensional Formula If you track the same type of information on separate sheets that are together (no other sheets between them) and your sheets are structurally the same, you can create a summary sheet using 3-D summary functions. To understand this, consider this example: You are tracking three years of sales for 4 different sales regions. Each region is on a separate sheet, but the categories and numbers for those categories are all in the same cells on each sheet: You want to summarize the numbers on a summary sheet: 3. Click on the first sheet for your summary and click in the cell that contains the number for the summary. The copy marquis appears around the cell and you see the formula with the sheet name and cell reference in the formula bar. 4. Group your sheets by holding the SHIFT key and clicking the last sheet in your group. The formula in the formula bar shows the sum function with the range between sheets (Eastern:Western). 5. Press Enter to finish the formula. 6. Copy the formula to the other cells. NOTE: Be cautious about rearranging, inserting or deleting sheets, rows, or columns when using this type of formula. Creating and Editing Range Names A range name is an alternate name for a cell or range of cells. Range names can be workbook wide, which means they can be used on any sheet in the workbook. They are also always an absolute reference. Both these attributes make range names particularly useful for lookup functions where the lookup table or range is often on a different sheet and would always need to be an absolute reference in a formula. To create a range name: 1. Select the cell or cells. 2. On the Formulas ribbon, select Define Name In this example, the 2013 Heavy Metals sales figure is always in cell B7, the Leaves sales figure is always in cell B8, etc. This is what is meant by structurally the same. To summarize using a 3-D formula: 1. Click in the first cell on the summary sheet. 2. Enter the sum function with nothing in the 3. Type the Name you want a. Range names cannot contain spaces use an underscore. b. Range names can contain numbers but cannot start with a number. parentheses. Make sure your cursor is inside the Corporate Training Group, Inc. 120 Wood Avenue S, Iselin, NJ 08830 (732)635-9033 Page 2
c. Do not use special characters like a slash (/). 4. The Scope should be Workbook if you want to use the range name throughout the file. 5. Click OK. To edit or delete a range name: 1. On the Formulas ribbon, select Name Manager. 2. Select the name to edit or delete. 3. Click the Edit or Delete button. The VLookup Function The VLookup function allows you to look up a value placed in a cell on one sheet in the first column of a table (either on the sheet or on another sheet) and return a corresponding value from another column in that table. Example: In this example, the VLookup would be used to look up Item # 103 and return the description. Here is the table: table range The table that stores the possible look up values and related information. In our example this is A5:D10 and has been given the range name Items. column number The number of the column that contain the corresponding information you want. Start counting with 1 where 1 is the column containing the look up values. In our example, we are lookup for description, which is column 2 (Item# is the column containing lookup value, so that would be 1). range lookup Asks the question Is the table a range lookup table?. A range lookup table (APPROXIMATE MATCH) does not contain every possible lookup value (see below). The table in our example contains all possible items, so our table would be an EXACT MATCH table, not a range lookup table. The value can be either TRUE (range lookup) or FALSE (exact match). In our example, the final VLookup formula would look like this: =VLOOKUP(B9,Items,2,FALSE) Example of an approximate match table: If you were looking for the shipping charge for an order amount of $250.30, you would not find that in column 1 of the above table as an exact match. Using approximate match as the last argument of the VLookup would match to the closest, lower value ($200). The lookup column must be in ascending order The IF Function The IF function allows you to perform a logical test (returns true or false) on a cell or value and have Excel return different values dependent on the test being true or false. The structure of the IF function is: Item Number is column 1 in this table (which has the range name Items). It is important that the lookup column is the first column in your lookup range and that the number or text is unique to that row. Once the VLookup finds Item #103, it needs to return the Description (Digital Camera) in the second column of the lookup table range. The VLookup Function is: =VLOOKUP(lookup value, table range, column number, range lookup) Argument Explanation lookup value The value on the worksheet that you want to look up. In the above example that is cell B12. =IF(logical test, value if true, value if false) In Excel, the logical test is often comparing a value in a cell to another value. To make comparisons, use the following operators: > Greater than < Less than = Equal <> Not Equal >= Greater than or equal <= Less than or equal Corporate Training Group, Inc. 120 Wood Avenue S, Iselin, NJ 08830 (732)635-9033 Page 3
Simple IF function example: In this example, reward points are given for every dollar spent over $1000. If the order total is below $1000, there should be zero points. 1. The logical test would be to test if the Order total is greater than $1000: E16>1000 2. If the logical test is true, the calculation for reward points would be: E16-1000 3. If the logical test is false, the result would be 0 4. The final formula would look like this: =IF(E16>1000,E16-1000,0) The AND function The AND function allows you to perform multiple logical tests and returns TRUE if ALL the logical tests performed are true. You can perform up to 255 logical tests. The structure of the AND function is: =AND(logical test 1, logical test 2, logical 255) Because the AND function returns only a logical value (TRUE if all logical tests produce TRUE values; FALSE if even one of the logical tests performed produces FALSE), it is often nested within an IF function as a logical test. Nesting an AND function in an IF function The structure for an AND function used as the logical test for an IF function looks like this: =IF(AND(logical test 1, logical test 2),value if true, value if false) An example of the AND function being used with an IF function: In this example, rewards points would be awarded, but only if 2 conditions are met: the Order Total must still be above $1000, but the customer would also need to use Store Credit (Store Credit as the payment method in B6). 1. The AND function would be used as the logical test, since both conditions must be true (Order Total > $1000 AND Payment Method=Store Credit): AND(E16>1000,B6= Store Credit ) E19>1000 B8= Store Credit AND result TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE 2. The value if true and false would remain the same as the original IF, so the final formula would look like this: =IF(AND(E16>1000,B6= Store Credit ),E16-1000,0) The OR Function The OR function also allows you to perform multiple logical tests, but returns TRUE if ANY of the logical tests performed are true. You can perform up to 255 logical tests. The structure of the OR function is: =OR(logical test 1, logical test 2, logical 255) Because the OR function returns only a logical value (TRUE if all logical tests produce TRUE values; FALSE if even one of the logical tests performed produces FALSE), it is often nested within an IF function as a logical test. Nesting an OR function in an IF function The structure for an OR function used as the logical test for an IF function looks like this: =IF(OR(logical test 1, logical test 2),value if true, value if false) You can also nest OR functions within AND functions (or vice versa) and use this as the logical test within an IF function: =IF(AND(logical test 1, OR(logical test 2,logical test 3),value if true, value if false) In the case above, the IF function logical test would have a TRUE result if logical test 1 was true and EITHER logical test 2 OR logical test 3 was true. Corporate Training Group, Inc. 120 Wood Avenue S, Iselin, NJ 08830 (732)635-9033 Page 4
Example: The IFERROR would look like this for the Description column: =IFERROR(VLOOKUP(B9,Items,2,FALSE),"") For the Price column: =IFERROR(VLOOKUP(B9,Items,4,FALSE),"") For the Total column: =IFERROR(A9*D9,"") NOTE: The alternate value can be either text or a number. Text needs to be contained in double quotes. A blank is represented by 2 double-quotes. In this example, the rewards points should be awarded if the Order Total is above $1000 AND the Payment Method is EITHER Store Credit OR Cash. 1. To check for one of 2 values for the Payment Method in cell B8: OR(B6= Store Credit,B6= Cash ) B8= Store Credit B8= Cash OR result TRUE TRUE TRUE (although this would not happen in the same cell TRUE FALSE TRUE FALSE TRUE TRUE FALSE FALSE FALSE The CONCATENATE Function Joins several text strings into one text string. =CONCATENATE(B2,", ",A2) The RIGHT or LEFT function Returns the specified number of characters from the end of a text string. =RIGHT(B1,5) The IFERROR function Returns an alternate value if the result of a formula would return an error. The structure of the IFERROR function is: =IFERROR(formula, alternate value in place of error) Sometimes errors appear in formulas simply because you copy a formula to an area where you do not have the input the formula requires yet. For example, if we copied the lookup formulas in our previous example down into rows 14 through 18 (where we do not have quantity or item # yet), the formulas return errors: Formula Auditing Tools The Formula Audition features will help you ensure accurate formula results. 1. Select a cell containing a formula. 2. On the Formulas ribbon choose Trace Precedents Or 3. Select a cell used in a formula. 4. On the Formulas ribbon choose Trace Dependents. In this case, for the error in each cell, you might want to just show a blank. Corporate Training Group, Inc. 120 Wood Avenue S, Iselin, NJ 08830 (732)635-9033 Page 5