Formulas and Functions
Formulas and Functions
Simple Formulas
One of the most powerful features in Excel is the ability to calculate numerical information using
formulas. Just like a calculator, Excel can add, subtract, multiply, and divide. In this lesson, we'll
show you how to use cell references to create simple formulas.
Mathematical operators
Excel uses standard operators for formulas, such as a plus sign for addition (+), a minus sign for
subtraction (-), an asterisk for multiplication (*), a forward slash for division (/), and a caret (^) for
exponents.
All formulas in Excel must begin with an equal sign (=). This is because the cell contains, or is equal
to, the formula and the value it calculates.
While you can create simple formulas in Excel manually (for example, =2+2 or =5*5), most of the
time you will use cell addresses to create a formula. This is known as making a cell reference. Using
cell references will ensure that your formulas are always accurate because you can change the value
of referenced cells without having to rewrite the formula.
By combining a mathematical operator with cell references, you can create a variety of simple
formulas in Excel. Formulas can also include a combination of cell references and numbers, as in the
examples below:
To create a formula:
In our example below, we'll use a simple formula and cell references to calculate a budget.
1. Select the cell that will contain the formula. In our example, we'll select cell B3.
2. Type the equals sign (=). Notice how it appears in both the cell and the formula
bar.
3. Type the cell address of the cell you want to reference first in the formula: cell
B1 in our example. A blue border will appear around the referenced cell.
4. Type the mathematical operator you want to use. In our example, we'll type
the addition sign (+).
5. Type the cell address of the cell you want to reference second in the formula:
cell B2 in our example. A red border will appear around the referenced cell.
6. Press Enter on your keyboard. The formula will be calculated, and the value will
be displayed in the cell.
If the result of a formula is too large to be displayed in a cell, it may appear as pound signs (#######)
instead of a value. This means the column is not wide enough to display the cell content. Simply
increase the column width to show the cell content.
The true advantage of cell references is that they allow you to update data in your worksheet
without having to rewrite formulas. In the example below, we've modified the value of cell B1 from
$1,200 to $1,800. The formula in B3 will automatically recalculate and display the new value in cell
B3.
Excel will not always tell you if your formula contains an error, so it's up to you to check all of your
formulas. To learn how to do this, you can read the Double-Check Your Formulas lesson from our
Excel Formulas tutorial.
Rather than typing cell addresses manually, you can point and click on the cells you want to include
in your formula. This method can save a lot of time and effort when creating formulas. In our
example below, we'll create a formula to calculate the cost of ordering several boxes of plastic
silverware.
1. Select the cell that will contain the formula. In our example, we'll select cell D3.
6. Press Enter on your keyboard. The formula will be calculated, and the value will
be displayed in the cell.
Formulas can also be copied to adjacent cells with the fill handle, which can save a lot of time and
effort if you need to perform the same calculation multiple times in a worksheet. Review our lesson
on Relative and Absolute Cell References to learn more.
To edit a formula:
Sometimes you may want to modify an existing formula. In the example below, we've entered an
incorrect cell address in our formula, so we'll need to correct it.
1. Select the cell containing the formula you want to edit. In our example, we'll
select cell B3.
2. Click the formula bar to edit the formula. You can also double-click the cell to
view and edit the formula directly within the cell.
3. A border will appear around any referenced cells. In our example, we'll change
the second part of the formula to reference cell B2 instead of cell C2.
4. When you're finished, press Enter on your keyboard or click the checkmark in
the formula bar.
5. The formula will be updated, and the new value will be displayed in the cell.
If you change your mind, you can press the Esc key on your keyboard to avoid accidentally making
changes to your formula.
To show all of the formulas in a spreadsheet, you can hold the Ctrl key and press ` (grave accent).
The grave accent key is usually located in the top-left corner of the keyboard. You can press Ctrl+`
again to switch back to the normal view.
Laboratory Activity
1. Create a simple addition formula using cell references. If you are using the
example, create the formula in cell B4 to calculate the total budget.
2. Try modifying the value of a cell referenced in a formula. If you are using the
example, change the value of cell B2 to $2,000. Notice how the formula in cell
B4 recalculates the total.
3. Try using the point-and-click method to create a formula. If you are using the
example, create a formula in cell G5 that multiplies the cost of napkins by the
quantity needed to calculate the total cost.
4. Edit a formula using the formula bar. If you are using the example, edit the
formula in cell B9 to change the division sign (/) to a minus sign (-).
Complex Formulas
A simple formula is a mathematical expression with one operator, such as 7+9. A complex formula
has more than one mathematical operator, such as 5+2*8. When there is more than one operation
in a formula, the order of operations tells Excel which operation to calculate first. In order to use
Excel to calculate complex formulas, you will need to understand the order of operations
A mnemonic that can help you remember the order is PEMDAS, or Please Excuse My Dear Aunt
Sally.
Click the arrows in the slideshow below to learn more about how the order of operations is used to
calculate formulas in Excel.
While this formula may look complicated, we can use the order of operations step by step to
find the right answer.
First, we'll start by calculating anything inside the parentheses. In this case, there's only one
thing we need to calculate: 6-3=3.
•
As you can see, the formula already looks simpler. Next, we'll look to see if there are any
exponents. There's one: 2^2=4.
Next, we'll solve any multiplication and division, working from left to right. Because the
division operation comes before the multiplication, it is calculated first: 3/4=0.75.
Next, we'll calculate any addition or subtraction, again working from left to right. Addition
comes first: 10+3=13.
•
• Now we have our answer: 12. This is the exact same result you would get if you entered the
formula into Excel.
Excel follows the order of operations and first adds the values inside the parentheses: (44.85+39.90)
= $84.75. It then multiplies that value by the tax rate: $84.75*0.075. The result will show that the
sales tax is $6.36.
It is especially important to enter complex formulas with the correct order of operations. Otherwise,
Excel will not calculate the results accurately. In our example, if the parentheses are not included,
the multiplication is calculated first and the result is incorrect. Parentheses are the best way to
define which calculations will be performed first in Excel.
In our example below, we will use cell references along with numerical values to create a complex
formula that will calculate the total cost for a catering invoice. The formula will calculate the cost for
each menu item and then add those values together.
1. Select the cell that will contain the formula. In our example, we'll select cell C4.
2. Enter your formula. In our example, we'll type =B2*C2+B3*C3. This formula will
follow the order of operations, first performing the multiplication: 2.29*20 = 45.80
and 3.49*35 = 122.15. It then will add those values together to calculate the total:
45.80+122.15.
3. Double-check your formula for accuracy, then press Enter on your keyboard. The
formula will calculate and display the result. In our example, the result shows that
the total cost for the order is $167.95.
You can add parentheses to any equation to make it easier to read. While it won't change the result
of the formula in this example, we could enclose the multiplication operations within parentheses to
clarify that they will be calculated before the addition.
Excel will not always tell you if your formula contains an error, so it's up to you to check all of your
formulas. To learn how to do this, you can read the Double-Check Your Formulas lesson from our
Excel Formulas tutorial.
Laboratory Activity
There are two types of cell references: relative and absolute. Relative and absolute references
behave differently when copied and filled to other cells. Relative references change when a formula
is copied to another cell. Absolute references, on the other hand, remain constant, no matter where
they are copied.
Relative references
By default, all cell references are relative references. When copied across multiple cells, they change
based on the relative position of rows and columns. For example, if you copy the formula =A1+B1
from row 1 to row 2, the formula will become =A2+B2. Relative references are especially convenient
whenever you need to repeat the same calculation across multiple rows or columns.
In the following example, we want to create a formula that will multiply each item's price by the
quantity. Instead of creating a new formula for each row, we can create a single formula in cell D2
and then copy it to the other rows. We'll use relative references so the formula correctly calculates
the total for each item.
1. Select the cell that will contain the formula. In our example, we'll select cell D2.
Selecting cell D2
2. Enter the formula to calculate the desired value. In our example, we'll type
=B2*C2.
Entering the formula
3. Press Enter on your keyboard. The formula will be calculated, and the result
will be displayed in the cell.
4. Locate the fill handle in the bottom-right corner of the desired cell. In our
example, we'll locate the fill handle for cell D2.
5. Click, hold, and drag the fill handle over the cells you want to fill. In our
example, we'll select cells D3:D12.
Dragging the fill handle over cells D3:D12
6. Release the mouse. The formula will be copied to the selected cells with
relative references, and the values will be calculated in each cell.
You can double-click the filled cells to check their formulas for accuracy. The relative cell references
should be different for each cell, depending on their rows.
Checking the copied formulas for accuracy
Absolute references
There may be times when you do not want a cell reference to change when filling cells. Unlike
relative references, absolute references do not change when copied or filled. You can use an
absolute reference to keep a row and/or column constant.
An absolute reference is designated in a formula by the addition of a dollar sign ($). It can precede
the column reference, the row reference, or both.
You will generally use the $A$2 format when creating formulas that contain absolute references.
The other two formats are used much less frequently.
When writing a formula, you can press the F4 key on your keyboard to switch between relative and
absolute cell references, as shown in the video below. This is an easy way to quickly insert an
absolute reference.
In our example, we'll use the 7.5% sales tax rate in cell E1 to calculate the sales tax for all items in
column D. We'll need to use the absolute cell reference $E$1 in our formula. Because each formula
is using the same tax rate, we want that reference to remain constant when the formula is copied
and filled to other cells in column D.
1. Select the cell that will contain the formula. In our example, we'll select cell D3.
Selecting cell D3
2. Enter the formula to calculate the desired value. In our example, we'll type
=(B3*C3)*$E$1.
3. Press Enter on your keyboard. The formula will calculate, and the result will
display in the cell.
4. Locate the fill handle in the bottom-right corner of the desired cell. In our
example, we'll locate the fill handle for cell D3.
Locating the fill handle
5. Click, hold, and drag the fill handle over the cells you want to fill: cells D4:D13
in our example.
6. Release the mouse. The formula will be copied to the selected cells with an
absolute reference, and the values will be calculated in each cell.
The copied formulas and calculated values
You can double-click the filled cells to check their formulas for accuracy. The absolute reference
should be the same for each cell, while the other references are relative to the cell's row.
Be sure to include the dollar sign ($) whenever you're making an absolute reference across multiple
cells. The dollar signs were omitted in the example below. This caused Excel to interpret it as a
relative reference, producing an incorrect result when copied to other cells.
The result of an incorrect absolute reference
Excel allows you to refer to any cell on any worksheet, which can be especially helpful if you want to
reference a specific value from one worksheet to another. To do this, you'll simply need to begin the
cell reference with the worksheet name followed by an exclamation point (!). For example, if you
wanted to reference cell A1 on Sheet1, its cell reference would be Sheet1!A1.
Note that if a worksheet name contains a space, you will need to include single quotation marks (' ')
around the name. For example, if you wanted to reference cell A1 on a worksheet named July
Budget, its cell reference would be 'July Budget'!A1.
In our example below, we'll refer to a cell with a calculated value between two worksheets. This will
allow us to use the exact same value on two different worksheets without rewriting the formula or
copying data between worksheets.
1. Locate the cell you want to reference, and note its worksheet. In our example,
we want to reference cell E14 on the Menu Order worksheet.
Cell E14
2. Navigate to the desired worksheet. In our example, we'll select the Catering
Invoice worksheet.
Navigating to Sheet2
Selecting cell B2
5. Type the equals sign (=), the sheet name followed by an exclamation point (!),
and the cell address. In our example, we'll type ='Menu Order'!E14.
6. Press Enter on your keyboard. The value of the referenced cell will appear. If
the value of cell E14 changes on the Menu Order worksheet, it will be updated
automatically on the Catering Invoice worksheet.
If you rename your worksheet at a later point, the cell reference will be updated automatically to
reflect the new worksheet name.
If you enter a worksheet name incorrectly, the #REF! error will appear in the cell. In our example
below, we've mistyped the name of the worksheet. Click the Error button and select the desired
option from the drop-down menu to edit or ignore the error.
Laboratory Activity
1. Open an existing Excel workbook. If you want, you can use our practice
workbook.
2. Create a formula that uses a relative reference. If you are using the example,
use the fill handle to fill in the formula in cells E4 through E14. Double-click a
cell to see the copied formula and the relative cell references.
3. Create a formula that uses an absolute reference. If you are using the example,
correct the formula in cell D4 to refer only to the tax rate in cell E2 as an
absolute reference, then use the fill handle to fill the formula from cells D4 to
D14.
4. Try referencing a cell across worksheets. If you are using the example, create a
cell reference in cell B3 on the Catering Invoice worksheet for cell E15 on the
Menu Order worksheet.
FUNCTIONS
A function is a predefined formula that performs calculations using specific values in a particular
order. Excel includes many common functions that can be useful for quickly finding the sum,
average, count, maximum value, and minimum value for a range of cells. In order to use functions
correctly, you'll need to understand the different parts of a function and how to create arguments
to calculate values and cell references
In order to work correctly, a function must be written a specific way, which is called the syntax. The
basic syntax for a function is the equals sign (=), the function name (SUM, for example), and one or
more arguments. Arguments contain the information you want to calculate. The function in the
example below would add the values of the cell range A1:A20.
Arguments can refer to both individual cells and cell ranges and must be enclosed within
parentheses. You can include one argument or multiple arguments, depending on the syntax
required for the function.
For example, the function =AVERAGE(B1:B9) would calculate the average of the values in the cell
range B1:B9. This function contains only one argument.
A function with a single argument
Multiple arguments must be separated by a comma. For example, the function =SUM(A1:A3, C1:C2,
E1) will add the values of all the cells in the three arguments.
Creating a function
Excel has a variety of functions available. Here are some of the most common functions you'll use:
• SUM: This function adds all of the values of the cells in the argument.
• AVERAGE: This function determines the average of the values included in the
argument. It calculates the sum of the cells and then divides that value by the
number of cells in the argument.
• COUNT: This function counts the number of cells with numerical data in the
argument. This function is useful for quickly counting items in a cell range.
• MAX: This function determines the highest cell value included in the argument.
• MIN: This function determines the lowest cell value included in the argument.
1. Select the cell that will contain the function. In our example, we'll select cell
C11.
2. Type the equals sign (=) and enter the desired function name. You can also
select the desired function from the list of suggested functions that will appear
below the cell as you type. In our example, we'll type =AVERAGE.
Creating an argument
4. Press Enter on your keyboard. The function will be calculated, and the result
will appear in the cell. In our example, the average price per unit of items
ordered was $15.93.
The AutoSum command allows you to automatically insert the most common functions into your
formula, including SUM, AVERAGE, COUNT, MIN, and MAX. In our example below, we'll create a
function to calculate the total cost for a list of recently ordered items using the SUM function.
1. Select the cell that will contain the function. In our example, we'll select cell
D12.
2. In the Editing group on the Home tab, locate and select the arrow next to the
AutoSum command and then choose the desired function from the drop-down
menu. In our example, we'll select Sum.
4. Press Enter on your keyboard. The function will be calculated, and the result
will appear in the cell. In our example, the sum of D3:D11 is $606.05.
The AutoSum command can also be accessed from the Formulas tab on the Ribbon.
Accessing the AutoSum command from the Formulas tab
You can also use the Alt+= keyboard shortcut instead of the AutoSum command. To use this
shortcut, hold down the Alt key and then press the equals sign.
While there are hundreds of functions in Excel, the ones you use most frequently will depend on the
type of data your workbooks contains. There is no need to learn every single function, but exploring
some of the different types of functions will be helpful as you create new projects. You can search
for functions by category, such as Financial, Logical, Text, Date & Time, and more from the Function
Library on the Formulas tab.
• To access the Function Library, select the Formulas tab on the Ribbon. The
Function Library will appear.
Click the buttons in the interactive below to learn more about the different types of functions in
Excel.
To insert a function from the Function Library:
In our example below, we'll use a function to calculate the number of business days it took to
receive items after they were ordered. In our example, we'll use the dates in columns B and C to
calculate the delivery time in column D.
1. Select the cell that will contain the function. In our example, we'll select cell D3.
Selecting cell D3
2. Click the Formulas tab on the Ribbon to access the Function Library.
3. From the Function Library group, select the desired function category. In our
example, we'll choose Date & Time.
Selecting the Date & Time category from the Function Library
4. Select the desired function from the drop-down menu. In our example, we'll
select the NETWORKDAYS function to count the number of business days
between the ordered date and received date.
5. The Function Arguments dialog box will appear. From here, you'll be able to
enter or select the cells that will make up the arguments in the function. In our
example, we'll enter B3 in the Start_date: field and C3 in the End_date: field.
6. When you're satisfied with the arguments, click OK.
Clicking OK
7. The function will be calculated, and the result will appear in the cell. In our
example, the result shows that it took four business days to receive the order.
Like formulas, functions can be copied to adjacent cells. Hover the mouse over the cell that contains
the function, then click, hold, and drag the fill handle over the cells you want to fill. The function will
be copied, and values for those cells will be calculated relative to their rows or columns.
Copying a function to adjacent cells using the fill handle
If you're having trouble finding the right function, the Insert Function command allows you to search
for functions using keywords. While it can be useful, this command is sometimes difficult to use. If
you don't have much experience with functions, you may have more success browsing the Function
Library instead. For more advanced users, however, the Insert Function command can be a powerful
way to find a function quickly.
In our example below, we want to find a function that will count the total number of items ordered.
We want to count the cells in the Item column, which uses text. We cannot use the basic COUNT
function because it will only count cells with numerical information. Instead, we will need to find a
function that counts the total number of cells within a cell range.
1. Select the cell that will contain the function. In our example, we'll select cell
B16.
Selecting cell B16
2. Click the Formulas tab on the Ribbon, then select the Insert Function
command.
5. Review the results to find the desired function, then click OK. In our example,
we'll choose COUNTA because it will count the number of cells in a cell range.
8. The function will be calculated, and the result will appear in the cell. In our
example, the result shows that a total of eight items were ordered.
Laboratory Activity