You are on page 1of 11

Advanced Microsoft Excel: Formulas and Functions

Introduction
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 Excel’s 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 Excel’s 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 Last Modified 9/30/2005


I. Naming Cells and Ranges

Naming Cells and Ranges


Naming ranges in Excel will save you time when writing complex formulas and maneuvering your
worksheets. For example, if you have a range of cells used in several formulas or charts, naming
those cells will allow you to select them whenever you need to. Naming a single cell will allow you
to quickly jump to a specific location in your document.

1. First highlight the cell(s) you would like to


name.

2. Click inside the “Name” box on your toolbar. It


will be on the left. Once you have clicked inside
the box, the cell name will highlight (Figure 1).

3. Type the name you would like for your cell(s)


and press the Enter key. If you receive a
naming error, check the following:
a. Names can not have spaces in them (Figure 1)
b. Names can not be the same as a cell
reference (i.e. A1).
c. Names can not begin with a number.
d. Names can not use certain characters.

Example: Using named ranges in formulas

1. In Cells A1 through E1, type random


numbers (Figure 2).

2. Select cells A1 through E1 and name them.


The cells in the example have been named
(Figure 2)
“Numbers” (Figure 2). This is called a
named range.

3. Move to another area in your workbook


and click in any cell.

4. Type the formula, =SUM(named range),


and you will receive of the sum of what’s
(Figure 3)
in your named range of cells (Figure 3).

5. Another example, type the formula


=SUMIF(named range,"<6") and you
will get the sum of all numbers in your
range less than 6 (Figure 4).
(Figure 4)

Page 2 of 11 Last Modified 9/30/2005


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.

Naming a Constant or Formula

Another way to create a formula or constant is to do it outside of a cell.

1. Go to the Insert menu and then Name. Click Define.

2. In the Names in workbook field, enter the name for the formula.

3. In the Refers to field, type = (equal sign), followed by the formula or the constant value.

Note: When using your named cells in creating new formulas, pressing the F3 key while writing your
formula will bring up the Paste Name box. To use this box, double click the named cell you would like
to add to your formula and it will be inserted into your formula.

Note: The Paste Name box is the only place you will find your formulas and constants that do not refer
to specific cells.

Note: To create a list of your named references, select the cell you would like the list to start in. Press
F3. In the Paste Name box, click Paste List. This creates a list of named references that you can refer
back to or print for future use.

Page 3 of 11 Last Modified 9/30/2005


II. Manipulating Formulas
Switch between relative, absolute, and mixed references
After you have written a formula you may want to paste or drag it to different parts of your
workbook. To aid in this, Excel has been designed to adjust your formula’s references to reflect the
formula’s new location. There are times, however, when the formula needs to maintain constant cell
references. Changing the cell reference from relative to absolute will allow you to do this.

1. Select the cell that contains the formula.

2. In the formula bar, select the reference you want to change.

3. Press F4 to toggle through the combinations. The dollar sign signifies which part of the
formula will remain the same when you dragging or pasting a formula.

Example

=B1*B4

=B7*B10
=B6*B9
=B5*B8
=B4*B7
=B3*B6
=B2*B5
(Figure 6)
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)
(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
(Figure 8)
formula is dragged.

Page 4 of 11 Last Modified 9/30/2005


Replace a formula with its result

You can "freeze" a formula to prevent its recalculation


and maintain its present calculated value.

1. Select the cell(s) that contains the formula.

2. Go to the Edit menu and select Copy.

3. Go to the Edit menu and select Paste Special.

4. In the Paste Special box, under paste, select the


radio button next to Values (Figure 9). Click
OK. This will permanently remove the formula
from your work book. If you have accidentally
removed a formula immediately click Undo in
the Edit menu.
(Figure 9)
Replace part of a formula with its calculated value

You can replace individual parts of a formula while maintaining the rest of the formula.

1. Click the cell that contains the formula you would like to change.

2. In the formula bar, select the portion of the formula you want to replace with its calculated
value. For example, if you select a function, you must select the entire function name, the
opening parenthesis, the arguments, and the closing parenthesis.

3. After you have made your selection, press F9 to calculate the selected portion.

4. Press ENTER. This will permanently replace that part of your formula. If you have made a
mistake, immediately click Undo in the Edit menu.

Example

(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 Last Modified 9/30/2005
III. Conditional Functions
IF Functions
Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to
FALSE. An IF function has the following format IF(logical_test,value_if_true,value_if_false)

logical_test: the value or expression that is determined to be true of false. For example, A1<20
could be used as a logical test.

value_if_true: the value returned if the test is determined to be true. This value can be a value,
word, etc. or it can return the value of another cell.

value_if_false: the value returned if the test is determined to be false. This value can be a value,
word, etc. or it can return the value of another cell.

Example

1. In this example, we
are calculating the
student’s final
grade. To do this
we need our formula
to determine which
Midterm Exam the
student scored
highest on.

(Figure 11)
2. In cell E2 (Figure 11) we have calculated Suzy’s 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. Suzy’s final grade was calculated using the value_if_true statement.

Page 6 of 11 Last Modified 9/30/2005


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 student’s final grade (column E) into a letter grade
(column F).

2. The formula used to calculate Suzy’s 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 Last Modified 9/30/2005


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 Suzy’s 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 Self-
Test 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 Suzy’s 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 Last Modified 9/30/2005


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).

2. In cell E2, we have calculated the


number of A letter grades using the
formula: =COUNTIF($B$2:$B$8,“A”)

(Figure 14)
3. The range ($B$2:$B$8) includes each student’s 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 Last Modified 9/30/2005


IV. Lookup Functions
Lookup functions search a value or text in the top row or column of a selected set of cells, and then
returns a value from a row or column from the same set of cells. HLOOKUP is used when your search
values are on the top row. VLOOKUP is used when your search values are in the leftmost column.

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 Last Modified 9/30/2005


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 student’s type was recorded in relation to their name.
The VLOOKUP formula will use the student’s 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
the author. Users agree to respect and not to alter, remove or conceal any copyright, trademark, trade name or other
Idaho State University
Campus Box 8064 proprietary marking that may appear in the manual. Please send comments to itrc@isu.edu. For more information
Pocatello, ID 83209 about the ITRC, visit our Website at http://www.isu.edu/itrc.
208.282.5880

Page 11 of 11 Last Modified 9/30/2005

You might also like