Back to Tutorial
#### Lesson 16: Functions

### Introduction

#### The parts of a function

#### Working with arguments

### Creating a function

#### To create a basic function:

#### To create a function using the AutoSum command:

### The Function Library

### Insert Function

### AutoSum Command

### Recently Used

### Financial

### Logical

### Text

### Date & Time

### Lookup & Reference

### Math & Trig

### More Functions

#### To insert a function from the Function Library:

### The Insert Function command

#### To use the Insert Function command:

### Challenge!

/en/excel2013/relative-and-absolute-cell-references/content/

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

Optional: Download our practice workbook.

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.

Syntax of a basic function

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.

A function with multiple arguments

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.

In our example below, we'll create a basic function to calculate the **average price** **per unit **for a list of recently ordered items using the AVERAGE function.

- Select the
**cell**that will contain the function. In our example, we'll select cell**C11**.Selecting cell C11 - 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**.Entering the AVERAGE function - Enter the
**cell range**for the**argument**inside**parentheses**. In our example, we'll type**(C3:C10)**. This formula will add the values of cells C3:C10 and then divide that value by the total number of cells in the range to determine the average.Creating an argument - 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 completed function and calculated value

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, read the Double-Check Your Formulas lesson from our Excel Formulas tutorial.

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.

- Select the
**cell**that will contain the function. In our example, we'll select cell**D12**.Selecting cell D12 - 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**.Selecting Sum from the AutoSum command drop-down menu - The selected
**function**will appear in the cell. If logically placed, the AutoSum command will**automatically**select a cell range for the argument. In our example, cells**D3:D11**were selected automatically and their values will be**added**together to calculate the total cost. You can also manually enter the desired cell range into the argument.The inserted function and automatically selected cell range - 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 completed function and calculated value

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

Watch the video below to see this shortcut in action.

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.Clicking the Formulas tab

Click the buttons in the interactive below to learn more about the different types of functions in Excel.

If you're having trouble finding the right function, the Insert Function command allows you to search for functions using keywords.

The AutoSum command allows you to automatically return results for common functions, like SUM, AVERAGE, and COUNT.

The Recently Used command gives you access to functions you've recently worked with.

The Financial category contains functions for financial calculations like determining a payment (PMT) or interest rate for a loan (RATE).

Functions in the Logical category check arguments for a value or condition. For example, if an order is more than $50 add $4.99 for shipping, but if it is more than $100 do not charge for shipping (IF).

The Text category contains functions that work with the text in arguments to perform tasks, such as converting text to lowercase (LOWER) or replacing text (REPLACE).

The Date & Time category contains functions for working with dates and time and will return results like the current date and time (NOW) or the seconds (SECOND).

The Lookup & Reference category contains functions that will return results for finding and referencing information. For example, you can add a hyperlink (HYPERLINK) to a cell or return the value of a particular row and column intersection (INDEX).

The Math & Trig category includes functions for numerical arguments. For example, you can round values (ROUND), find the value of Pi (PI) multiply (PRODUCT), and subtotal (SUBTOTAL).

More Functions contains additional functions under categories for Statistical, Engineering, Cube, Information, and Compatibility.

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

- Select the
**cell**that will contain the function. In our example, we'll select cell**D3**.Selecting cell D3 - Click the
**Formulas**tab on the**Ribbon**to access the**Function Library**. - 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 - 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.Selecting the NETWORKDAYS function - 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. - When you're satisfied with the arguments, click
**OK**.Clicking OK - 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.The completed function and calculated value

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.

- Select the
**cell**that will contain the function. In our example, we'll select cell**B16**.Selecting cell B16 - Click the
**Formulas**tab on the**Ribbon**, then select the**Insert Function**command.Selecting the Insert Function command - The
**Insert Function**dialog box will appear. - Type a few
**keywords**describing the calculation you want the function to perform, then click**Go**. In our example, we'll type**Count****cells**, but you can also search by selecting a**category**from the drop-down list.Searching for a function with keywords - 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.Selecting a function and clicking OK - The
**Function Arguments**dialog box will appear. Select the**Value1:**field, then enter or select the desired cells. In our example, we'll enter the cell range**A3:A10**. You may continue to add arguments in the**Value2**: field, but in this case we only want to count the number of cells in the cell range**A3:A10**. - When you're satisfied, click
**OK**.Entering an argument and clicking OK - 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.The completed function and calculated value

If you're comfortable with basic functions, you may want to try a more advanced one like **VLOOKUP**. You can check out our article on How to Use Excel's VLOOKUP Function for more information. If you want to learn even more about functions, check out our Excel Formulas tutorial.

- Open an existing Excel workbook. If you want, you can use our practice workbook.
- Create a function that contains one
**argument**. If you're using the example, use the**SUM**function in cell**B16**to calculate the total quantity of items ordered. - Use the
**AutoSum**command to insert a function. If you are using the example, insert the**MAX**function in cell**B23**and use the cell range**D3:D15**for the argument to find the most expensive item that was ordered. - Explore the
**Function****Library,**and try using the**Insert****Function**command to search for different types of functions.

/en/excel2013/freezing-panes-and-view-options/content/