Advanced Excel Formulas and Functions
Advanced Excel Formulas and Functions
This guide was developed as an extension of the Microsoft Excel Fundamentals handout. To fully use this guide one must have an understanding of the components of Excels layout, how to create a spreadsheet, how to create basic formulas, how to adjust column and row width, and how to change basic cell formatting. You will go over the creation of named cells and constants and their use in formulas and maneuvering your workbook. This is followed by the introduction of tools that allow you manipulate functions and construct new ones for more specialized uses. Examples of conditional and Lookup functions will provide you with powerful tools for getting the most out of Excel. Other ITRC Advanced Microsoft Excel guides will help you utilize the advanced formatting features in Excel as well as prepare your workbook for printing and the creation of templates. Data management is introduced using Microsoft Excels tools for Data Validation, lists, and filtering. To obtain these guides, please contact the ITRC.
Topics
I. Naming Ranges, Cells, and Constants II. Manipulating Formulas III. Conditional Functions IV. Lookup Functions
Page 1 of 11
(Figure 1)
(Figure 3)
Page 2 of 11
Example: Using Named Cells 1. Go to Sheet 1 and click inside of cell A1. Type Idaho State University and press Enter on the keyboard (Figure 5). 2. Click back inside cell A1, and in the Name Box, and type in ISU (Figure 5). Press Enter on the (Figure 5) keyboard. 3. Go to cell A30 and type University of Idaho in that cell and press Enter. Now click back on cell A30. In the Name Box, type UI and press Enter on the keyboard. 4. Go and click cell A80 and type in Boise State University. In the name box, type BSU and press Enter. 5. For practice, repeat these steps in cell A100 and A120 using other schools. 6. Move to any other sheet (or anywhere within this sheet) and select one of the schools from the name box. Excel will take you to the named cell you select.
Page 3 of 11
=B1*B4
=B2*B5
(Figure 6)
=B3*B6
=B4*B7
=B5*B8
=B6*B9
=B7*B10
1. The original formula was put into cell C4 to calculate the total points earned by Suzy on Assignment 1. When dragged to the other students, however, it failed to calculate the points correctly. By looking at the formulas in Column C, you can see that each cell down used a different cell for Total Points Possible rather than maintaining its reference to B1 (Figure 6). 2. To fix this dragging problem, we will select cell C4. In the formula window, highlight the reference to cell B1 (Figure 7) 3. Now, press the F4 button. Notice the dollar signs that now appear before the B and the 1. These dollar signs will prevent these references from changing when the formula is dragged.
(Figure 7)
(Figure 8)
Page 4 of 11
(Figure 9)
(Figure 9)
1. If you look in the formula window you can see that the formula for cell C4 is =B1*B4. We have selected the reference to cell B1 in the formula window (Figure 9). 2. Now press F9. You can see that the B1 in the formula was replaced with its value of 100 (Figure 10).
(Figure 10)
Page 5 of 11
2. In cell E2 (Figure 11) we have calculated Suzys final grade by entering the formula =IF(C2>B2,(C2+D2)/2,(B2+D2)/2). logical_test: C2>B2 value_if_true: (C2+D2)/2 value_if_false: (B2+D2)/2 3. Because the score in cell C2 was higher than the score in cell B2, the logical test was determined to be true. Suzys final grade was calculated using the value_if_true statement.
Page 6 of 11
Nested Ifs
Up to eight IF functions can be nested to construct more complicated tests. Example
1. In this example, we need to turn the students final grade (column E) into a letter grade (column F). 2. The formula used to calculate Suzys letter grade (cell F2 Figure 22) was: =IF(E2>94.4,"A",IF(E2>89.4,"A-",IF(E2>84.5,"B",IF(E2>79.4,"B-" ,IF(E2>74.4,"C",IF(E2>69.4,"C-",IF(E2>64.5,"D","F"))))))) 3. Because the logical_test (E2>94.4) is false, Excel uses the value_if_false. In this case, however, the value_if_false is new IF statement instead of a value or cell reference. The logical_test for the next IF statement is (E2>89.4). This Test, for Suzy, is true so the value_if_true is used. Suzy will receive an A-. 4. Notice that the formula started with the highest grade and moved down to the smallest grade. If the formula had started with the smallest percentage grade everyone would receive a D because their grades all greater than 64.5! Keep in mind that IF statements are applied chronologically.
Page 7 of 11
SUMIF
SUMIF and COUNTIF functions give you the ability to either add or tally a range of cells based on a specific criteria. Only those cells that meet the criteria are included in the final count. A sumif function has the following format: =SUMIF(range,criteria,sum_range) range: specifies the cells you want the function to evaluate. criteria: is a number, phrase, or text that determines which cells will be added. sum_range: defines which cells will be summed based on the determined criteria. The cells chosen here will only be added if the cells in Range meat the Criteria. If you choose not to include a sum_range the cells in the range will be summed. Example
(Figure 13)
1. In this example, the professor gave the students three uncounted self-tests. To encourage the
students to do their best, however, ten extra-credit points were offered for each test if the student scored 85 or above (Figure 13). The professor now needs to determine the total extra-credit earned by each student.
2. The formula used to calculate Suzys total extra-credit was =SUMIF(B3:D3,>84,$B$1:$D$1) 3. The range (B3:D3) will be evaluated by the criteria (>84). For Suzy, Self-Test 1 and SelfTest 2 failed to meet the criteria (>84) because they were less than 85. Self-Test 3, however, was 87 and the function moved to the sum_range ($B$1:$D$1) to find the corresponding value to add to Suzys extra credit total. Note: The sum_range ($B$1:$D$1) has dollar signs preceding each cell reference to keep it constant as the formula was dragged.
Page 8 of 11
COUNTIF
A countif function has the following format: =COUNTIF(range,criteria) range: determines the cells the function will count from. criteria: is a number, phrase, or text that determines which of the selected cells will be counted. Example 1. In this example, the professor wants to
see how the grades were distributed across the class to determine if a curve is needed (Figure 14).
3. The range ($B$2:$B$8) includes each students final letter grade. The criteria (A) specifies
which grade is being counted. In cell E3, where the number of A-s are counted, the range is the same as the formula in cell E2, but the criteria becomes an A-.
Page 9 of 11
VLOOKUP
A VLOOKUP function has the following format: =VLOOKUP(lookup_value,table_array,col_index_num,range_lookup) lookup_value: the value, text or reference the function will find in the first column of the array. table_array: the cell selection that the lookup_value will be searched for. col_index_num: determines which column the returned value comes from. range_lookup: either true or false and specifies whether you want VLOOKUP to find an exact match. If the field is TRUE or omitted and an exact match is not found, the next largest value that is less than lookup_value is returned. If TRUE is selected, however, the values in the first column of table_array must be in ascending order (sort command from data menu). If the field is FALSE, VLOOKUP will look only for an exact match and will return #N/A if one is not found. If FALSE is selected, that table_array will not need to be selected.
HLOOKUP
A HLOOKUP function has the following format: =HLOOKUP(lookup_value,table_array,row_index_num,range_lookup) Lookup_value: the value, text or reference the function will find in the first row of the array. Table_array: the cell selection that the lookup_value will be searched for. Col_index_num: determines which row the returned value comes from. Range_lookup: either true or false and specifies whether you want HLOOKUP to find an exact match or an approximate match. If the field is TRUE or omitted and an exact match is not found, the next largest value that is less than lookup_value is returned. If TRUE is selected, however, the values in the first column of table_array must be in ascending order (sort command from data menu). If the field is FALSE, HLOOKUP will look only for an exact match and will return #N/A if one is not found. If FALSE is selected, that table_array will not need to be selected.
Page 10 of 11
Example
1. In this example, the professor was teaching a class that could be taken by four different types of students: graduates working towards 6 credits, graduates working towards 3 credits, undergraduates, and students auditing the course. Because each type of student was given different responsibilities, the maximum earnable points varied between student types. Using a VLOOKUP will allow the professor to change their maximum point values as the semester progresses without changing each individuals total possible points. 2. In cells A1 through B4 the student type and Total Points Possible were entered. This is where the professor will make changes to the point values when needed. 3. In cell B8, and continuing down, each students type was recorded in relation to their name. The VLOOKUP formula will use the students type to assign the appropriate number of points. 4. The formula in cell D8 calculating the total possible points Suzy could earn is as follows: =VLOOKUP so (B8,$A$2:$B$5,2,FALSE) The Lookup_value (B8) refers to the student status the professor determined at the beginning of the semester. Excel then goes to the Table_array ($A$2:$B$5) to find a corresponding match in the first column of the array. After a match is made, it goes to the column in the Table_array indicated by the Col_index_num (2). Because the Range_lookup is false, the formula will look for an exact match only.
Copyright 2005 by ITRC This document may be reproduced for individual or nonprofit use. Users acknowledge that the manual, and all copyright and other intellectual and proprietary rights therein, are and at all times shall remain the valuable property of Idaho State University Campus Box 8064 Pocatello, ID 83209 208.282.5880 the author. Users agree to respect and not to alter, remove or conceal any copyright, trademark, trade name or other proprietary marking that may appear in the manual. Please send comments to itrc@isu.edu. For more information about the ITRC, visit our Website at http://www.isu.edu/itrc.
Page 11 of 11