
This page presents how to work with Microsoft Excel 2007 features and its redesigned interface. You may also visit our Excel Question page.

Overview of formulas
Formulas are equations that perform calculations on values in your worksheet. A formula starts with an equal sign (=). For example, the following formula multiplies 2 by 3 and then adds 5 to the result.
=5+2*3
A formula can also contain any or all of the following: functions (function: A prewritten formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that perform lengthy or complex calculations.), references, operators (operator: A sign or symbol that specifies the type of calculation to perform within an expression. There are mathematical, comparison, logical, and reference operators.), and constants (constant: A value that is not calculated and, therefore, does not change. For example, the number 210, and the text "Quarterly Earnings" are constants. An expression, or a value resulting from an expression, is not a constant.).
Parts of a formula
Functions: The PI() function returns the value of pi: 3.142...
References: A2 returns the value in cell A2.
Constants: Numbers or text values entered directly into a formula, such as 2.
Operators: The ^ (caret) operator raises a number to a power, and the * (asterisk) operator multiplies.
In this article
Using constants in formulas
Using calculation operators in formulas
Using functions and nested functions in formulas
Using references in formulas
Using names in formulas
Using array formulas and array constants
Using constants in formulas
A constant is a value that is not calculated. For example, the date 10/9/2008, the number 210, and the text "Quarterly Earnings" are all constants. An expression, or a value resulting from an expression, is not a constant. If you use constant values in the formula instead of references to the cells (for example, =30+70+110), the result changes only if you modify the formula yourself.
Top of Page
Using calculation operators in formulas
Operators specify the type of calculation that you want to perform on the elements of a formula. There is a default order in which calculations occur, but you can change this order by using parentheses.
Types of operators
There are four different types of calculation operators: arithmetic, comparison, text concatenation, and reference.
Arithmetic operators
To perform basic mathematical operations such as addition, subtraction, or multiplication; combine numbers; and produce numeric results, use the following arithmetic operators.
Arithmetic operator

Meaning

Example

+ (plus sign)

Addition

3+3

– (minus sign)

Subtraction
Negation

3–1
–1

* (asterisk)

Multiplication

3*3

/ (forward slash)

Division

3/3

% (percent sign)

Percent

20%

^ (caret)

Exponentiation)

3^2

Comparison operators
You can compare two values with the following operators. When two values are compared by using these oper
Comparison operator

Meaning

Example

= (equal sign)

Equal to

A1=B1

> (greater than sign)

Greater than

A1>B1

< (less than sign)

Less than

A1

>= (greater than or equal to sign)

Greater than or equal to

A1>=B1

<= (less than or equal to sign)

Less than or equal to

A1<=B1

<> (not equal to sign)

Not equal to

A1<>B1

ators, the result is a logical value either TRUE or FALSE.
Text concatenation operator
Use the ampersand (&) to join, or concatenate, one or more text strings to produce a single piece of text.
Text operator

Meaning

Example

& (ampersand)

Connects, or concatenates, two values to produce one continuous text value

"North"&"wind"

Reference operators
Combine ranges of cells for calculations with the following operators.
Reference operator

Meaning

Example

: (colon)

Range operator, which produces one reference to all the cells between two references, including the two references

B5:B15

, (comma)

Union operator, which combines multiple references into one reference

SUM(B5:B15,D5:D15)

(space)

Intersection operator, which produces on reference to cells common to the two references

B7:D7 C6:C8

The order in which Excel performs operations in formulas
In some cases, the order in which calculation is performed can affect the return value of the formula, so it's important to understand how the order is determined and how you can change the order to obtain desired results.
Calculation order
Formulas calculate values in a specific order. A formula in Excel always begins with an equal sign (=). The equal sign tells Excel that the succeeding characters constitute a formula. Following the equal sign are the elements to be calculated (the operands), which are separated by calculation operators. Excel calculates the formula from left to right, according to a specific order for each operator in the formula.
Operator precedence
If you combine several operators in a single formula, Excel performs the operations in the order shown in the following table. If a formula contains operators with the same precedence — for example, if a formula contains both a multiplication and division operator — Excel evaluates the operators from left to right.
Operator

Description

: (colon)
(single space)
, (comma)

Reference operators

–

Negation (as in –1)

%

Percent

^

Exponentiation

* and /

Multiplication and division

+ and –

Addition and subtraction

&

Connects two strings of text (concatenation)

=
< >
<=
>=
<>

Comparison

Use of parentheses
To change the order of evaluation, enclose in parentheses the part of the formula to be calculated first. For example, the following formula produces 11 because Excel calculates multiplication before addition. The formula multiplies 2 by 3 and then adds 5 to the result.
=5+2*3
In contrast, if you use parentheses to change the syntax, Excel adds 5 and 2 together and then multiplies the result by 3 to produce 21.
=(5+2)*3
In the example below, the parentheses around the first part of the formula force Excel to calculate B4+25 first and then divide the result by the sum of the values in cells D5, E5, and F5.
=(B4+25)/SUM(D5:F5)
Top of Page
Using functions and nested functions in formulas
Functions are predefined formulas that perform calculations by using specific values, called arguments, in a particular order, or structure. Functions can be used to perform simple or complex calculations.
The syntax of functions
The following example of the ROUND function rounding off a number in cell A10 illustrates the syntax of a function.
Structure of a function
Structure. The structure of a function begins with an equal sign (=), followed by the function name, an opening parenthesis, the arguments for the function separated by commas, and a closing parenthesis.
Function name. For a list of available functions, click a cell and press SHIFT+F3.
Arguments. Arguments can be numbers, text, logical values such as TRUE or FALSE, arrays (array: Used to build single formulas that produce multiple results or that operate on a group of arguments that are arranged in rows and columns. An array range shares a common formula; an array constant is a group of constants used as an argument.), error values such as #N/A, or cell references (cell reference: The set of coordinates that a cell occupies on a worksheet. For example, the reference of the cell that appears at the intersection of column B and row 3 is B3.). The argument you designate must produce a valid value for that argument. Arguments can also be constants (constant: A value that is not calculated and, therefore, does not change. For example, the number 210, and the text "Quarterly Earnings" are constants. An expression, or a value resulting from an expression, is not a constant.), formulas, or other functions.
Argument tooltip. A tooltip with the syntax and arguments appears as you type the function. For example, type =ROUND( and the tooltip appears. Tooltips only appear for builtin functions.
Entering functions
When you create a formula that contains a function, the Insert Function dialog box helps you enter worksheet functions. As you enter a function into the formula, the Insert Function dialog box displays the name of the function, each of its arguments, a description of the function and each argument, the current result of the function, and the current result of the entire formula.
To make it easier to create and edit formulas and minimize typing and syntax errors, use formula autocomplete. After you type an = (equal sign) and beginning letters or a display trigger, Microsoft Office Excel displays below the cell a dynamic drop down list of valid functions, arguments, and names that match the letters or trigger. You can then insert an item in the dropdown list into the formula.
Nesting functions
In certain cases, you may need to use a function as one of the arguments (argument: The values that a function uses to perform operations or calculations. The type of argument a function uses is specific to the function. Common arguments that are used within functions include numbers, text, cell references, and names.) of another function. For example, the following formula uses a nested AVERAGE function and compares the result with the value 50.
The AVERAGE and SUM functions are nested within the IF function.
Valid returns When a nested function is used as an argument, it must return the same type of value that the argument uses. For example, if the argument returns a TRUE or FALSE value, then the nested function must return a TRUE or FALSE. If it doesn't, Microsoft Excel displays a #VALUE! error value.
Nesting level limits A formula can contain up to seven levels of nested functions. When Function B is used as an argument in Function A, Function B is a secondlevel function. For instance, the AVERAGE function and the SUM function are both secondlevel functions because they are arguments of the IF function. A function nested within the AVERAGE function would be a thirdlevel function, and so on.
Top of Page
Using references in formulas
A reference identifies a cell or a range of cells on a worksheet and tells Microsoft Excel where to look for the values or data you want to use in a formula. With references, you can use data contained in different parts of a worksheet in one formula or use the value from one cell in several formulas. You can also refer to cells on other sheets in the same workbook, and to other workbooks. References to cells in other workbooks are called links or external references (external reference: A reference to a cell or range on a sheet in another Excel workbook, or a reference to a defined name in another workbook.).
The A1 reference style
The default reference style By default, Excel uses the A1 reference style, which refers to columns with letters (A through XFD, for a total of 16,384 columns) and refers to rows with numbers (1 through 1,048,576). These letters and numbers are called row and column headings. To refer to a cell, enter the column letter followed by the row number. For example, B2 refers to the cell at the intersection of column B and row 2.
To refer to

Use

The cell in column A and row 10

A10

The range of cells in column A and rows 10 through 20

A10:A20

The range of cells in row 15 and columns B through E

B15:E15

All cells in row 5

5:5

All cells in rows 5 through 10

5:10

All cells in column H

H:H

All cells in columns H through J

H:J

The range of cells in columns A through E and rows 10 through 20

A10:E20

Making a reference to another worksheet In the following example, the AVERAGE worksheet function calculates the average value for the range B1:B10 on the worksheet named Marketing in the same workbook.
Reference to a range of cells on another worksheet in the same workbook
Refers to the worksheet named Marketing
Refers to the range of cells between B1 and B10, inclusively
Separates the worksheet reference from the cell range reference
The difference between absolute, relative and mixed references
Relative references A relative cell reference in a formula, such as A1, is based on the relative position of the cell that contains the formula and the cell the reference refers to. If the position of the cell that contains the formula changes, the reference is changed. If you copy or fill the formula across rows or down columns, the reference automatically adjusts. By default, new formulas use relative references. For example, if you copy or fill a relative reference in cell B2 to cell B3, it automatically adjusts from =A1 to =A2.
Copied formula with relative reference
Absolute references An absolute cell reference in a formula, such as $A$1, always refer to a cell in a specific location. If the position of the cell that contains the formula changes, the absolute reference remains the same. If you copy or fill the formula across rows or down columns, the absolute reference does not adjust. By default, new formulas use relative references, and you may need to switch them to absolute references. For example, if you copy or fill an absolute reference in cell B2 to cell B3, it stays the same in both cells =$A$1.
Copied formula with absolute reference
Mixed references A mixed reference has either an absolute column and relative row, or absolute row and relative column. An absolute column reference takes the form $A1, $B1, and so on. An absolute row reference takes the form A$1, B$1, and so on. If the position of the cell that contains the formula changes, the relative reference is changed, and the absolute reference does not change. If you copy or fill the formula across rows or down columns, the relative reference automatically adjusts, and the absolute reference does not adjust. For example, if you copy or fill a mixed reference from cell A2 to B3, it adjusts from =A$1 to =B$1.
Copied formula with mixed reference
The 3D reference style
Conveniently referencing multiple worksheets If you want to analyze data in the same cell or range of cells on multiple worksheets within the workbook, use a 3D reference. A 3D reference includes the cell or range reference, preceded by a range of worksheet names. Excel uses any worksheets stored between the starting and ending names of the reference. For example, =SUM(Sheet2:Sheet13!B5) adds all the values contained in cell B5 on all the worksheets between and including Sheet 2 and Sheet 13.

You can use 3D references to refer to cells on other sheets, to define names, and to create formulas by using the following functions: SUM, AVERAGE, AVERAGEA, COUNT, COUNTA, MAX, MAXA, MIN, MINA, PRODUCT, STDEV, STDEVA, STDEVP, STDEVPA, VAR, VARA, VARP, and VARPA.

3D references cannot be used in array formulas (array formula: A formula that performs multiple calculations on one or more sets of values, and then returns either a single result or multiple results. Array formulas are enclosed between braces { } and are entered by pressing CTRL+SHIFT+ENTER.).

3D references cannot be used with the intersection operator (operator: A sign or symbol that specifies the type of calculation to perform within an expression. There are mathematical, comparison, logical, and reference operators.) (a single space) or in formulas that use implicit intersection (implicit intersection: A reference to a range of cells, instead of a single cell, that is calculated like a single cell. If cell C10 contains the formula =B5:B15*5, Excel multiplies the value in cell B10 by 5 because cells B10 and C10 are in the same row.).
What happens when you move, copy, insert, or delete worksheets The following examples explain what happens when you move, copy, insert, or delete worksheets that are included in a 3D reference. The examples use the formula =SUM(Sheet2:Sheet6!A2:A5) to add cells A2 through A5 on worksheets 2 through 6.

Insert or copy If you insert or copy sheets between Sheet2 and Sheet6 (the endpoints in this example), Microsoft Excel includes all values in cells A2 through A5 from the added sheets in the calculations.

Delete If you delete sheets between Sheet2 and Sheet6, Excel removes their values from the calculation.

Move If you move sheets from between Sheet2 and Sheet6 to a location outside the referenced sheet range, Excel removes their values from the calculation.

Move an endpoint If you move Sheet2 or Sheet6 to another location in the same workbook, Excel adjusts the calculation to accommodate the new range of sheets between them.

Delete an endpoint If you delete Sheet2 or Sheet6, Excel adjusts the calculation to accommodate the range of sheets between them.
The R1C1 reference style
You can also use a reference style where both the rows and the columns on the worksheet are numbered. The R1C1 reference style is useful for computing row and column positions in macros (macro: An action or a set of actions that you can use to automate tasks. Macros are recorded in the Visual Basic for Applications programming language.). In the R1C1 style, Excel indicates the location of a cell with an "R" followed by a row number and a "C" followed by a column number.
When you record a macro, Excel records some commands by using the R1C1 reference style. For example, if you record a command such as clicking the AutoSum button to insert a formula that adds a range of cells, Excel records the formula by using R1C1 style, not A1 style, references.
You can turn the R1C1 reference style on or off by setting or clearing the R1C1 reference style check box under the Working with formulas section in the Formulas category of the Excel Settings dialog box that you display from the Microsoft Office Button .
Top of Page
Using names in formulas
You can create defined names (name: A word or string of characters that represents a cell, range of cells, formula, or constant value. Use easytounderstand names, such as Products, to refer to hard to understand ranges, such as Sales!C20:C30.) to represent cells, ranges of cells, formulas, constant (constant: A value that is not calculated and, therefore, does not change. For example, the number 210, and the text "Quarterly Earnings" are constants. An expression, or a value resulting from an expression, is not a constant.) values, or Excel tables. A name is a meaningful shorthand that makes it easier to understand the purpose of a cell reference (cell reference: The set of coordinates that a cell occupies on a worksheet. For example, the reference of the cell that appears at the intersection of column B and row 3 is B3.), constant (constant: A value that is not calculated. For example, the number 210 and the text "Quarterly Earnings" are constants. An expression, or a value resulting from an expression, is not a constant.), formula (formula: A sequence of values, cell references, names, functions, or operators in a cell that together produce a new value. A formula always begins with an equal sign (=).), or table (table: A collection of data about a particular subject that is stored in records (rows) and fields (columns).), each of which may be difficult to comprehend at first glance. The following information shows common examples of names and how they can improve clarity and understanding.
Example Type

Example with no name

Example with a name

Reference

=SUM(C20:C30)

=SUM(FirstQuarterSales)

Constant

=PRODUCT(A5,8.3)

=PRODUCT(Price,WASalesTax)

Formula

=SUM(VLOOKUP(A1,B1:F20,5,FALSE), —G5)

=SUM(Inventory_Level,—Order_Amt)

Table

C4:G36

=TopSales06

Types of names
There are several types of names you can create and use.
Defined name A name that represents a cell, range of cells, formula, or constant value. You can create your own defined name, and Excel sometimes creates a defined name for you, such as when you set a print area.
Table name A name for an Excel table, which is a collection of data about a particular subject that is stored in records (rows) and fields (columns). Excel creates a default Excel table name of "Table1", "Table2", and so on, each time you insert an Excel table, but you can change the name to make it more meaningful. For more information on Excel tables, see Using structured references with Excel tables.
Creating and entering names
You create a name by using the:

Name box on the formula bar This is best used for creating a workbook level name for a selected range.

Create a name from selection You can conveniently create names from existing row and column labels by using a selection of cells in the worksheet.

New Name dialog box This is best used for when you want more flexibility in creating names, such as specifying a local worksheet level scope or creating a name comment.
Note By default, names use absolute cell references (absolute cell reference: In a formula, the exact address of a cell, regardless of the position of the cell that contains the formula. An absolute cell reference takes the form $A$1.).
You can enter a name by:

Typing Typing the name, for example, as an argument to a formula.

Using Formula AutoComplete Use the Formula AutoComplete dropdown list, where valid names are automatically listed for you.

Selecting from the Use in Formula command Select a defined name from a list available from the Use in Formula command in the Defined Names group on the Formula tab.
For more information, see Use names to clarify formulas.
Top of Page
Using array formulas and array constants
An array formula can perform multiple calculations and then return either a single result or multiple results. Array formulas act on two or more sets of values known as array arguments. Each array argument must have the same number of rows and columns. You create array formulas in the same way that you create other formulas, except you press CTRL+SHIFT+ENTER to enter the formula. Some of the builtin functions are array formulas, and must be entered as arrays to get the correct results.
Array constants can be used in place of references when you don't want to enter each constant value in a separate cell on the worksheet.
Using an array formula to calculate single and multiple results
When you enter an array formula (array formula: A formula that performs multiple calculations on one or more sets of values, and then returns either a single result or multiple results. Array formulas are enclosed between braces { } and are entered by pressing CTRL+SHIFT+ENTER.), Microsoft Excel automatically inserts the formula between { } (braces).
To calculate a single result This type of array formula can simplify a worksheet model by replacing several different formulas with a single array formula.
For example, the following calculates the total value of an array of stock prices and shares, without using a row of cells to calculate and display the individual values for each stock.
Array formula that produces a single result
When you enter the formula ={SUM(B2:D2*B3:D3)} as an array formula, it multiples the Shares and Price for each stock, and then adds the results of those calculations together.
To calculate multiple results Some worksheet functions return arrays of values, or require an array of values as an argument. To calculate multiple results with an array formula, you must enter the array into a range of cells that has the same number of rows and columns as the array arguments.
For example, given a series of three sales figures (in column B) for a series of three months (in column A), the TREND function determines the straightline values for the sales figures. To display all of the results of the formula, it is entered into three cells in column C (C1:C3).
Array formula that produces multiple results
When you enter the formula =TREND(B1:B3,A1:A3) as an array formula, it produces three separate results (22196, 17079, and 11962), based on the three sales figures and the three months.
Using array constants
In an ordinary formula, you can enter a reference to a cell containing a value, or the value itself, also called a constant (constant: A value that is not calculated and, therefore, does not change. For example, the number 210, and the text "Quarterly Earnings" are constants. An expression, or a value resulting from an expression, is not a constant.). Similarly, in an array formula you can enter a reference to an array, or enter the array of values contained within the cells, also called an array constant. Array formulas accept constants in the same way that nonarray formulas do, but you must enter the array constants in a certain format.
Array constants can contain numbers, text, logical values such as TRUE or FALSE, or error values such as #N/A. Different types of values can be in the same array constant — for example, {1,3,4;TRUE,FALSE,TRUE}. Numbers in array constants can be in integer, decimal, or scientific format. Text must be enclosed in double quotation marks — for example, "Tuesday".
Array constants cannot contain cell references, columns or rows of unequal length, formulas, or the special characters $ (dollar sign), parentheses, or % (percent sign).
When you format array constants, make sure you:

Enclose them in braces ( { } ).

Separate values in different columns with commas (,). For example, to represent the values 10, 20, 30, and 40, enter {10,20,30,40}. This array constant is known as a 1by4 array and is equivalent to a 1rowby4column reference.

Separate values in different rows with semicolons (;). For example, to represent the values 10, 20, 30, and 40 in one row and 50, 60, 70, and 80 in the row immediately below, you would enter a 2by4 array constant: {10,20,30,40;50,60,70,80}.
Top of Page
See Also
Excel > Formula and name basics > Creating formulas
Calculation operators and precedence
Operators specify the type of calculation that you want to perform on the elements of a formula. There is a default order in which calculations occur, but you can change this order by using parentheses.
In this article
Types of operators
The order in which Excel performs operations in formulas
Types of operators
There are four different types of calculation operators: arithmetic, comparison, text concatenation, and reference.
Arithmetic operators
To perform basic mathematical operations such as addition, subtraction, or multiplication; combine numbers; and produce numeric results, use the following arithmetic operators.
Arithmetic operator

Meaning

Example

+ (plus sign)

Addition

3+3

– (minus sign)

Subtraction
Negation

3–1
–1

* (asterisk)

Multiplication

3*3

/ (forward slash)

Division

3/3

% (percent sign)

Percent

20%

^ (caret)

Exponentiation

3^2

Comparison operators
You can compare two values with the following operators. When two values are compared by using these operators, the result is a logical value either TRUE or FALSE.
Comparison operator

Meaning

Example

= (equal sign)

Equal to

A1=B1

> (greater than sign)

Greater than

A1>B1

< (less than sign)

Less than

A1

>= (greater than or equal to sign)

Greater than or equal to

A1>=B1

<= (less than or equal to sign)

Less than or equal to

A1<=B1

<> (not equal to sign)

Not equal to

A1<>B1

Text concatenation operator
Use the ampersand (&) to join, or concatenate, one or more text strings to produce a single piece of text.
Text operator

Meaning

Example

& (ampersand)

Connects, or concatenates, two values to produce one continuous text value

("North"&"wind")

Reference operators
Combine ranges of cells for calculations with the following operators.
Reference operator

Meaning

Example

: (colon)

Range operator, which produces one reference to all the cells between two references, including the two references

B5:B15

, (comma)

Union operator, which combines multiple references into one reference

SUM(B5:B15,D5:D15)

(space)

Intersection operator, which produces on reference to cells common to the two references

B7:D7 C6:C8

Top of Page
The order in which Excel performs operations in formulas
In some cases, the order in which calculation is performed can affect the return value of the formula, so it's important to understand how the order is determined and how you can change the order to obtain desired results.
Calculation order
Formulas calculate values in a specific order. A formula in Excel always begins with an equal sign (=). The equal sign tells Excel that the succeeding characters constitute a formula. Following the equal sign are the elements to be calculated (the operands), which are separated by calculation operators. Excel calculates the formula from left to right, according to a specific order for each operator in the formula.
Operator precedence
If you combine several operators in a single formula, Excel performs the operations in the order shown in the following table. If a formula contains operators with the same precedence — for example, if a formula contains both a multiplication and division operator — Excel evaluates the operators from left to right.
Operator

Description

: (colon)
(single space)
, (comma)

Reference operators

–

Negation (as in –1)

%

Percent

^

Exponentiation

* and /

Multiplication and division

+ and –

Addition and subtraction

&

Connects two strings of text (concatenation)

=
< >
<=
>=
<>

Comparison

Use of parentheses
To change the order of evaluation, enclose in parentheses the part of the formula to be calculated first. For example, the following formula produces 11 because Excel calculates multiplication before addition. The formula multiplies 2 by 3 and then adds 5 to the result.
=5+2*3
In contrast, if you use parentheses to change the syntax, Excel adds 5 and 2 together and then multiplies the result by 3 to produce 21.
=(5+2)*3
In the example below, the parentheses around the first part of the formula force Excel to calculate B4+25 first and then divide the result by the sum of the values in cells D5, E5, and F5.
=(B4+25)/SUM(D5:F5)
Top of Page
Excel > Formula and name basics > Creating formulas
Use Excel as your calculator
Excel 2007
Instead of reaching for your calculator, use Microsoft Office Excel to do the math!
On a worksheet (worksheet: The primary document that you use in Excel to store and work with data. Also called a spreadsheet. A worksheet consists of cells that are organized into columns and rows; a worksheet is always stored in a workbook.), you can enter simple formulas (formula: A sequence of values, cell references, names, functions, or operators in a cell that together produce a new value. A formula always begins with an equal sign (=).) to add, divide, multiply, and subtract two or more numeric values. You can also enter a formula that uses the SUM function (also known as AutoSum) to quickly total a series of values without having to enter any of them manually in a formula. Once you have created a formula, you can fill it into adjacent cells — no need to create the same formula over and over again.
When you become familiar with these simple formulas, you may want to learn more about how to create complex formulas and try some of the many functions (function: A prewritten formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that perform lengthy or complex calculations.) that are available in Excel. For more information, see Overview of formulas and List of worksheet functions (by category).
What do you want to do?
Learn more about simple formulas
Use a simple formula to add, subtract, multiply, or divide numeric values
Use the SUM function to total numeric values in a column or row
Fill a formula into adjacent cells
Learn more about simple formulas
The first thing that you have to know is that all formula entries start with an equal sign (=). For simple formulas, you type the equal sign followed by the numeric values that you want to calculate and the math operators that you want to use — for example the plus sign (+) to add, the minus sign () to subtract, the asterisk (*) to multiply, and the forward slash (/) to divide the values that you enter. When you press ENTER, Excel instantly calculates and displays the result of the formula.
For example, when you type a simple formula in a cell ( for example, =12.99+16.99 in cell C6 in the following picture) and then press ENTER, Excel calculates the result and displays it in that cell. The formula itself appears in the formula bar (formula bar: A bar at the top of the Excel window that you use to enter or edit values or formulas in cells or charts. Displays the constant value or formula stored in the active cell.).
The formula that you enter in a cell remains visible in the formula bar, and you can see it whenever that cell is selected.
Click AutoSum, and voila!
To quickly total a series of values without having to enter any of them manually in a formula, you can enter a formula that uses the SUM function, also known as AutoSum.
AutoSum is the button that displays the "summation" symbol (the uppercase Sigma of the Greek alphabet). Within easy reach in two locations on the Ribbon, you can find this button on the Home tab in the Editing group and on the Formulas tab in the Function Library group.
When you select a cell to the right of or below a range of numeric values and then click AutoSum, Excel automatically includes that range in the formula and calculates the values.
Clicking AutoSum enters a formula that uses the SUM function to calculate the numeric values directly above or to the left of the selected cell.
For example, to quickly total the numbers for January, you just have to select cell B7 and then click AutoSum. A color marquee surrounds the cells that are selected in the formula that is entered in cell B7. After pressing ENTER, the result of the formula is displayed in the selected cell (B7), and the formula appears in the formula bar.
Cell B7 displays the result of the formula. The formula itself appears in the formula bar whenever that cell is selected.
In a formula that uses a function, such as SUM, the cell reference that appears inside the parentheses is the argument (argument: The values that a function uses to perform operations or calculations. The type of argument a function uses is specific to the function. Common arguments that are used within functions include numbers, text, cell references, and names.) of the formula. The argument determines which values the formula is going calculate. The colon (:) in the cell reference (B3:B6 in the example) indicates that the cell reference is a range (range: Two or more cells on a sheet. The cells in a range can be adjacent or nonadjacent.) of cells. Parentheses are always required in a formula that uses a function — they separate the argument from the function name in the formula.
When a cell reference is used in the argument of a formula instead of the actual values, Excel can automatically update the formula result whenever the values in the referenced cells are updated.
Stop typing the same formula over and over
Once you have created a formula, you can copy it to other cells — no need to create the same formula over and over again.
For example, when you copy the formula in cell B7 to the adjacent cell C7, the formula in that cell automatically adjusts to the new location, and calculates the numeric values in column C.
The copied formula references and calculates the numeric values in column C.
Top of Page
Use a simple formula to add, subtract, multiply, or divide numeric values
In a simple formula, you can enter values and math operators to calculate those values. However, instead of entering values directly in the formula, you can also refer to the cells that contain the values that you want to calculate. Using cell references (cell reference: The set of coordinates that a cell occupies on a worksheet. For example, the reference of the cell that appears at the intersection of column B and row 3 is B3.) in a formula makes sure that any changes to the values are automatically updated in the calculation result of the formula.

On a worksheet, click the cell in which you want to enter the formula.

To start the formula, type =

To enter the first numeric value, do one of the following:

Type the value that you want to use.
Tip For example, type 10


Select the cell that contains the value that you want to use.
Tip For example, select cell A1.

To enter the math operator that you want to use, do one of the following:

To use a plus sign (+) to add the values in the formula, type +

To use a minus sign () to subtract the values in the formula, type 

To use an asterisk (*) to multiply the values in the formula, type *

To use a forward slash (/) to divide the values in the formula, type /

To enter the next value numeric value, do the following:

Type the value that you want to use.
Tip For example, type 5.


Select the cell that contains the value that you want to use.
Tip For example, select cell B1.

Repeat steps 4 and 5 for any additional math operations and values that you want to include in the formula.
Tip For an operation to take precedence in the calculation, use parentheses around that operation. For example, type =(10+5)*2 or =(A1+B1)*C1.

When the formula is complete, press ENTER.
By default, the resulting value of the formula appears in the selected cell, and the formula itself is displayed in the formula bar.
Top of Page
Use the SUM function to total numeric values in a column or row
To calculate the total of a series of numeric values in a row or column, you do not have to enter all those values manually into a formula. Instead you can use a predefined formula that uses the SUM function.

On a worksheet, click a cell below or to the right of the numeric values that you want to total.

On the Home tab, in the Editing group, click AutoSum .
Tip AutoSum is also available on the Formulas tab, in the Function Library group.

Press ENTER to display the SUM function result in the selected cell.
The formula itself appears in the formula bar.
Tip If you are looking for an quick way to total values in a column, you may want to place your data in an Excel table. In an Excel table, you can add a total row so that you can instantly summarize the values in a column. For more information, see Overview of Excel tables.
Top of Page
Fill a formula into adjacent cells
When you fill a formula into adjacent cells, either in a row or column, the formula automatically adjusts to calculate the values in the corresponding row or column.

On a worksheet, select the cell that contains the formula that you want to fill into adjacent cells.

Drag the fill handle (fill handle: The small black square in the lowerright corner of the selection. When you point to the fill handle, the pointer changes to a black cross.) across the cells that you want to fill.
Note The fill handle is displayed by default, but if it is not available you must first specify an option in Excel to enable the fill handle.
For information about how to display the fill handle, see Display or hide the fill handle.

To specify how you want to fill the selection, click Auto Fill Options , and then click the option that you want.
Note If automatic workbook calculation is not enabled, formulas will not recalculate when you fill cells. To check your workbook calculation options, do the following:

Click the Microsoft Office Button , click Excel Options, and then click the Formulas category.

Under Calculation options, look under Workbook Calculation.
Tips

You can also fill the active cell with the formula of an adjacent cell by using the Fill command (on the Home tab in the Editing group) or by pressing CTRL+D to fill a cell below or CTRL+R to fill a cell to the right of the cell that contains the formula.

You can automatically fill a formula downward, for all adjacent cells that it applies to, by doubleclicking the fill handle of the first cell that contains the formula. For example, cells A1:A15 and B1:B15 contain numeric values, and you type the formula =A1+B1 in cell C1. To copy that formula into cells C2:C15 (so that C2=A2+B2, C3=A3+B3, and so on), select cell C1 and doubleclick the fill handle.

If you are looking for an even faster method for filling formulas, you may want to place your data in an Excel table. In an Excel table, you can create a calculated column by simply entering one formula, and Excel automatically uses that formula in the whole column. Magic math! For more information, see Overview of Excel tables.
Top of Page
See Also
Excel > Formula and name basics > Creating formulas
Guidelines and examples of array formulas
Excel 2007
To become an Excel power user, you need to know how to use array formulas, which can perform calculations that you can't do by using nonarray formulas. The following article is based on a series of Excel Power User columns written by Colin Wilcox and adapted from chapters 14 and 15 of Excel 2002 Formulas, a book written by John Walkenbach, an Excel MVP. To learn more about John's other books, see his book page.
In this article
Learn about array formulas
Learn about array constants
Putting basic array formulas to work
Putting advanced array formulas to work
Learn about array formulas
This section introduces array formulas and explains how to enter, edit, and troubleshoot them.
Why use array formulas?
If you have experience using formulas in Excel, you know that you can perform some fairly sophisticated operations. For example, you can calculate the total cost of a loan over any given number of years. However, if you really want to master formulas in Excel, you need to know how to use array formulas. You can use array formulas to do complex tasks, such as:

Count the number of characters that are contained in a range of cells.

Sum only numbers that meet certain conditions, such as the lowest values in a range or numbers that fall between an upper and lower boundary.

Sum every nth value in a range of values.
Note You may see array formulas referred to as "CSE formulas," because you press CTRL+SHIFT+ENTER to enter them into your workbooks.
A quick introduction to arrays and array formulas
If you've done even a little programming, you've probably run across the term array. For our purposes, an array is a collection of items. In Excel, those items can reside in a single row (called a onedimensional horizontal array), a column (a onedimensional vertical array), or multiple rows and columns (a twodimensional array). You cannot create threedimensional arrays or array formulas in Excel.
An array formula is a formula that can perform multiple calculations on one or more of the items in an array. Array formulas can return either multiple results or a single result. For example, you can place an array formula in a range of cells and use the array formula to calculate a column or row of subtotals. You can also place an array formula in a single cell and then calculate a single amount. An array formula that resides in multiple cells is called a multicell formula, and an array formula that resides in a single cell is called a singlecell formula.
The examples in the next section show you how to create multicell and singlecell array formulas.
Try it!
This exercise shows you how to use multicell and singlecell array formulas to calculate a set of sales figures. The first set of steps uses a multicell formula to calculate a set of subtotals. The second set uses a singlecell formula to calculate a grand total.
Create a multicell array formula

Open a new, blank workbook.

Copy the example worksheet data, and then paste it into the new workbook starting at cell A1.
How to copy the example worksheet data


Create a blank workbook or worksheet.

Select the example in the Help topic.
Note Do not select the row or column headers.
Selecting an example from Help


Press CTRL+C.

In the worksheet, select cell A1, and press CTRL+V.
Sales Person

Car Type

Number Sold

Unit Price

Total Sales




Barnhill

Sedan

5

2200



Coupe

4

1800


Ingle

Sedan

6

2300



Coupe

8

1700


Jordan

Sedan

3

2000



Coupe

1

1600


Pica

Sedan

9

2150



Coupe

5

1950


Sanchez

Sedan

6

2250



Coupe

8

2000



Use the Paste Options button that appears nearby to match the destination formatting.

To multiply the values in the array (the cell range C2 through D11), select cells E2 through E11, and then enter the following formula in the formula bar:
=C2:C11*D2:D11

Press CTRL+SHIFT+ENTER.
Excel surrounds the formula with braces ({ }) and places an instance of the formula in each cell of the selected range. This happens very quickly, so what you see in column E is the total sales amount for each car type for each salesperson.
Create a singlecell array formula

In cell A13 of the workbook, type Total Sales.

In cell B13, type the following formula, and then press CTRL+SHIFT+ENTER:
=SUM(C2:C11*D2:D11)
In this case, Excel multiplies the values in the array (the cell range C2 through D11) and then uses the SUM function to add the totals together. The result is a grand total of $111,800 in sales. This example shows how powerful this type of formula can be. For example, suppose you have 15,000 rows of data. You can sum part or all of that data by creating an array formula in a single cell.
Also, notice that the singlecell formula (in cell B13) is completely independent of the multicell formula (the formula in cells E2 through E11). This points to another advantage of using array formulas — flexibility. You can take any number of actions, such as changing the formulas in column E or deleting that column altogether, without affecting the singlecell formula.
Array formulas also offer these advantages:

Consistency If you click any of the cells from E2 downward, you see the same formula. That consistency can help ensure greater accuracy.

Safety You cannot overwrite a component of a multicell array formula. For example, click cell E3 and press DELETE. You have to either select the entire range of cells (E2 through E11) and change the formula for the entire array, or leave the array as is. As an added safety measure, you must press CTRL+SHIFT+ENTER to confirm the change to the formula.

Smaller file sizes You can often use a single array formula instead of several intermediate formulas. For example, the workbook you created for this exercise uses one array formula to calculate the results in column E. If you had used standard formulas (such as =C2*D2), you would have used 11 different formulas to calculate the same results.
A look at array formula syntax
For the most part, array formulas use standard formula syntax. They all begin with an equal sign, and you can use any of the builtin Excel functions in your array formulas. The key difference is that when using an array formula, you must press CTRL+SHIFT+ENTER to enter your formula. When you do this, Excel surrounds your array formula with braces — if you type the braces manually, your formula will be converted to a text string, and it will not work.
The next thing you need to understand is that array functions are a form of shorthand. For example, the multicell function that you used earlier is the equivalent of:
=C2*D2
=C3*D3
and so on. The singlecell formula in cell B13 condenses all of those multiplication operations, plus the arithmetic required to add those subtotals: =E2+E3+E4, and so on.
Rules for entering and changing array formulas
The primary rule for creating an array formula is worth repeating: Press CTRL+SHIFT+ENTER whenever you need to enter or edit an array formula. That rule applies to both singlecell and multicell formulas.
Whenever you work with multicell formulas, you also need to follow these rules:

You must select the range of cells to hold your results before you enter the formula. You did this in step 3 of the multicell array formula exercise when you selected cells E2 through E11.

You cannot change the contents of an individual cell in an array formula. To try this, select cell E3 in the sample workbook and press DELETE.

You can move or delete an entire array formula, but you cannot move or delete part of it. In other words, to shrink an array formula, you first delete the existing formula and then start over.
Tip To delete an array formula, select the entire formula (for example, =C2:C11*D2:D11), press DELETE, and then press CTRL+SHIFT+ENTER.

You cannot insert blank cells into or delete cells from a multicell array formula.
Expanding an array formula
At times, you may need to expand an array formula. (Remember that you cannot shrink an array formula.) The process is not complicated, but you must remember the rules listed in the previous section.

In the sample workbook, clear any text and singlecell formulas that are located below the main table.

Paste these additional lines of data into the workbook starting at cell A12. Use the Paste Options button that appears nearby to match the destination formatting.
Toth

Sedan

6

2500



Coupe

7

1900


Wang

Sedan

4

2200



Coupe

3

2000


Young

Sedan

8

2300



Coupe

8

2100



Select the range of cells that contains the current array formula (E2:E11), plus the empty cells (E12:E17) that are next to the new data. In other words, select cells E2:E17.

Press F2 to switch to edit mode.

In the formula bar, change C11 to C17, change D11 to D17, and then press CTRL+SHIFT+ENTER . Excel updates the formula in cells E2 through E11 and places an instance of the formula in the new cells, E12 through E17.
Disadvantages of using array formulas
Array formulas can seem magical, but they also have some disadvantages:

You may occasionally forget to press CTRL+SHIFT+ENTER. Remember to press this key combination whenever you enter or edit an array formula.

Other users may not understand your formulas. Array formulas are relatively undocumented, so if other people need to modify your workbooks, you should either avoid array formulas or make sure those users understand how to change them.

Depending on the processing speed and memory of your computer, large array formulas can slow down calculations.
Top of Page
Learn about array constants
This section introduces array constants and explains how to enter, edit, and troubleshoot them.
A brief introduction to array constants
Array constants are a component of array formulas. You create array constants by entering a list of items and then manually surrounding the list with braces ({ }), like so:
={1,2,3,4,5}
Earlier in this article, we emphasized the need to press CTRL+SHIFT+ENTER when you create array formulas. Because array constants are a component of array formulas, you surround the constants with braces manually by typing them. You then use CTRL+SHIFT+ENTER to enter the entire formula.
If you delimit (separate) the items by using commas, you create a horizontal array (a row). If you delimit the items by using semicolons, you create a vertical array (a column). To create a twodimensional array, you delimit the items in each row by using commas, and you delimit each row by using semicolons.
As with array formulas, you can use array constants with any of the builtin functions that Excel provides. The following sections explain how to create each kind of constant and how to use these constants with functions in Excel.
Create onedimensional and twodimensional constants
The following procedure will give you some practice in creating horizontal, vertical, and twodimensional constants.
Create a horizontal constant

Use the workbook from the previous column, or start a new workbook.

Select cells A1 through E1.

In the formula bar, enter the following formula, and then press CTRL+SHIFT+ENTER:
={1,2,3,4,5}
Note In this case, you should type the opening and closing braces ({ }).
You see the following result.
You may wonder why you can't just type the numbers manually. Keep going, because the Use constants in formulas section, later in this article, demonstrates the advantages of using array constants.
Create a vertical constant

In your workbook, select a column of five cells.

In the formula bar, enter the following formula and press CTRL+SHIFT+ENTER:
={1;2;3;4;5}
You see the following result.
Create a twodimensional constant

In your workbook, select a block of cells four columns wide by three rows high.

In the formula bar, enter the following formula, and then press CTRL+SHIFT+ENTER:
={1,2,3,4;5,6,7,8;9,10,11,12}
You see the following result:
Use constants in formulas
Now that you are familiar with entering array constants, here is a simple example that uses what we've discussed:

Open a blank worksheet.

Copy the following table starting at cell A1. Use the Paste Options button that appears nearby to match the destination formatting.
3

4

5

6

7


In cell A3, enter the following formula, and then press CTRL+SHIFT+ENTER:
=SUM(A1:E1*{1,2,3,4,5})
Notice that Excel surrounds the constant with another set of braces, because you entered it as an array formula.
The value 85 appears in cell A3. The next section explains how the formula works.
A look at the array constant syntax
The formula you just used contains several parts.
Function
Stored array
Operator
Array constant
The last element inside the parentheses is the array constant: {1,2,3,4,5}. Remember that Excel does not surround array constants with braces; you must do this. Also remember that after you add a constant to an array formula, you press CTRL+SHIFT+ENTER to enter the formula.
Because Excel performs operations on expressions enclosed in parentheses first, the next two elements that come into play are the values stored in the workbook (A1:E1) and the operator. At this point, the formula multiplies the values in the stored array by the corresponding values in the constant. It's the equivalent of:
=SUM(A1*1,B1*2,C1*3,D1*4,E1*5)
Finally, the SUM function adds the values, and the sum 85 appears in cell A3:
To avoid using the stored array and to just keep the operation entirely in memory, replace the stored array with another array constant:
=SUM({3,4,5,6,7}*{1,2,3,4,5})
To try this, copy the function, select a blank cell in your workbook, paste the formula into the formula bar, and then press CTRL+SHIFT+ENTER. You see the same result as you did in the earlier exercise that used the array formula =SUM(A1:E1*{1,2,3,4,5}).
Elements that you can use in constants
Array constants can contain numbers, text, logical values (such as TRUE and FALSE), and error values ( such as #N/A). You can use numbers in the integer, decimal, and scientific formats. If you include text, you must surround that text with double quotation marks (").
Array constants cannot contain additional arrays, formulas, or functions. In other words, they can contain only text or numbers that are separated by commas or semicolons. Excel displays a warning message when you enter a formula such as {1,2,A1:D4} or {1,2,SUM(Q2:Z8)}. Also, numeric values cannot contain percent signs, dollar signs, commas, or parentheses.
Naming array constants
Possibly the best way to use array constants is to name them. Named constants can be much easier to use, and they can hide some of the complexity of your array formulas from beginning users. To name an array constant and use it in a formula, do the following:

On the Formulas tab, in the Defined Names group, click Define Name.
The Define Name dialog box appears.

In the Name box, type Quarter1.

In the Refers to box, enter the following constant (remember to type the braces manually):
={"January","February","March"}
The contents of the dialog box should look like this:

Click OK.

On the worksheet, select a row of three blank cells.

Type the following formula, and then press CTRL+SHIFT+ENTER.
=Quarter1
You see the following result.
When you use a named constant as an array formula, remember to enter the equal sign. If you don't, Excel interprets the array as a string of text. Finally, keep in mind that you can use combinations of text and numbers.
Troubleshooting array constants
Look for the following problems when your array constants don't work:

Some elements might not be separated with the proper character. If you omit a comma or semicolon, or if you put one in the wrong place, the array constant may not be created correctly or you may see a warning message.

You may have selected a range of cells that doesn't match the number of elements in your constant. For example, if you select a column of six cells for use with a fivecell constant, the #N/A error value appears in the empty cell. Conversely, if you select too few cells, Excel omits the values that don't have a corresponding cell.
Array constants in action
The following examples demonstrate a few of the ways in which you can put array constants to use in array formulas. Some of the examples use the TRANSPOSE function to convert rows to columns and vice versa.
Multiply each item in an array

Select a block of empty cells four columns wide by three rows high.

Type the following formula, and then press CTRL+SHIFT+ENTER.
={1,2,3,4;5,6,7,8;9,10,11,12}*2
Square the items in an array

Select a block of empty cells four columns wide by three rows high.

Type the following array formula, and then press CTRL+SHIFT+ENTER.
={1,2,3,4;5,6,7,8;9,10,11,12}*{1,2,3,4;5,6,7,8;9,10,11,12}
Alternatively, enter this array formula, which uses the caret operator (^):
={1,2,3,4;5,6,7,8;9,10,11,12}^2
Transpose a onedimensional row

Select a column of five blank cells.

Type the following formula, and then press CTRL+SHIFT+ENTER:
=TRANSPOSE({1,2,3,4,5})
Even though you entered a horizontal array constant, the TRANSPOSE function converts the array constant into a column.
Transpose a onedimensional column

Select a row of five blank cells.

Enter the following formula, and then press CTRL+SHIFT+ENTER:
=TRANSPOSE({1;2;3;4;5})
Even though you entered a vertical array constant, the TRANSPOSE function converts the constant into a row.
Transpose a twodimensional constant

Select a block of cells three columns wide by four rows high.

Enter the following constant, and press CTRL+SHIFT+ENTER.
=TRANSPOSE({1,2,3,4;5,6,7,8;9,10,11,12})
The TRANSPOSE function converts each row into a series of columns.
Top of Page
Putting basic array formulas to work
This section provides examples of basic array formulas.
Get started
Use the data in this section to create two sample worksheets.

Open an existing workbook or create a new workbook, and make sure it contains two blank worksheets.

Copy the data in the following table, and paste it into the worksheet starting at cell A1.








400


the quick


1

2

3

4

1200


brown fox


5

6

7

8

3200


jumped over


9

10

11

12

475


the lazy


13

14

15

16

500


power user






2000








600








1700








800








2700

















Your finished worksheet should look like this.




Name the first worksheet Data, and name a second blank worksheet Arrays.
Create arrays and array constants from existing values
The following example explains how to use array formulas to create links between ranges of cells in different worksheets. It also shows you how to create an array constant from the same set of values.
Create an array from existing values

In your sample workbook, select the Arrays worksheet.

Select the cell range C1 through E3.

Enter the following formula in the formula bar, and then press CTRL+SHIFT+ENTER:
=Data!E1:G3
You see the following result.
The formula links to the values stored in cells E1 through G3 on the Data worksheet. The alternative to this multicell array formula is to place a unique formula in each cell of the Arrays worksheet, as follows.



=Data!E1

=Data!F1

=Data!G1

=Data!E2

=Data!F2

=Data!G2

=Data!E3

=Data!F3

=Data!G3




If you change some of the values on the Data worksheet, those changes appear on the Arrays worksheet. Remember that to change any values on the Data worksheet, you have to follow the rules for editing array formulas. For more information about those rules, see the section Learn about array formulas.
Create an array constant from existing values

On the Arrays worksheet, select cells C1 through E3.

Press F2 to switch to edit mode.

Press F9 to convert the cell references to values. Excel converts the values into an array constant.

Press CTRL+SHIFT+ENTER to enter the array constant as an array formula.
Excel replaces the =Data!E1:G3 array formula with the following array constant:
={1,2,3;5,6,7;9,10,11}
The link has been broken between the Data and Arrays worksheets, and the array formula has been replaced by an array constant.
Count characters in a range of cells
The following example shows you how to count the number of characters, including spaces, in a range of cells.

On the Data worksheet, enter the following formula in cell C7, and then press CTRL+SHIFT+ENTER:
=SUM(LEN(C1:C5))
The value 47 appears in cell C7.
In this case, the LEN function returns the length of each text string in each of the cells in the range. The SUM function then adds those values together and displays the result in the cell that contains the formula, C7.
Find the n smallest values in a range
This example shows how to find the three smallest values in a range of cells.

On the Data worksheet, select cells A12 through A14.
This set of cells will hold the results returned by the array formula.

In the formula bar, enter the following formula, and then press CTRL+SHIFT+ENTER:
=SMALL(A1:A10,{1;2;3})
The values 400, 475, and 500 appear in cells A12 through A14, respectively.
This formula uses an array constant to evaluate the SMALL function three times and return the smallest (1), second smallest (2), and third smallest (3) members in the array that is contained in cells A1:A10. To find more values, you add more arguments to the constant and an equivalent number of result cells to the A12:A14 range. You can also use additional functions with this formula, such as SUM or AVERAGE. For example:
=SUM(SMALL(A1:A10,{1;2;3}))
=AVERAGE(SMALL(A1:A10,{1;2;3}))
Find the n largest values in a range
To find the largest values in a range, you can replace the SMALL function with the LARGE function. In addition, the following example uses the ROW and INDIRECT functions.

On the Data worksheet, select cells A12 through A14.

Press DELETE to clear the existing formula but leave the cells selected.

In the formula bar, enter this formula, and then press CTRL+SHIFT+ENTER:
=LARGE(A1:A10,ROW(INDIRECT("1:3")))
The values 3200, 2700, and 2000 appear in cells A12 through A14, respectively.
At this point, it may help to know a bit about the ROW and INDIRECT functions. You can use the ROW function to create an array of consecutive integers. For example, select an empty column of 10 cells in your practice workbook, enter this array formula in cells A1:A10, and then press CTRL+SHIFT+ENTER:
=ROW(1:10)
The formula creates a column of 10 consecutive integers. To see a potential problem, insert a row above the range that contains the array formula (that is, above row 1). Excel adjusts the row references, and the formula generates integers from 2 to 11. To fix that problem, you add the INDIRECT function to the formula:
=ROW(INDIRECT("1:10"))
The INDIRECT function uses text strings as its arguments (which is why the range 1:10 is surrounded by double quotation marks). Excel does not adjust text values when you insert rows or otherwise move the array formula. As a result, the ROW function always generates the array of integers that you want.
Let us examine the formula that you used earlier — =LARGE(A1:A10,ROW(INDIRECT("1:3"))) — starting from the inner parentheses and working outward: The INDIRECT function returns a set of text values, in this case the values 1 through 3. The ROW function in turn generates a threecell columnar array. The LARGE function uses the values in the cell range A1:A10, and it is evaluated three times, once for each reference returned by the ROW function. The values 3200, 2700, and 2000 are returned to the threecell columnar array. If you want to find more values, you add a greater cell range to the INDIRECT function.
Finally, you can use this formula with other functions, such as SUM and AVERAGE.
Find the longest text string in a range of cells
This example finds the longest string of text in a range of cells. This formula works only when a data range contains a single column of cells.

On the Data worksheet, clear the existing formula from cell C7, enter the following formula in that cell, and then press CTRL+SHIFT+ENTER:
=INDEX(C1:C5,MATCH(MAX(LEN(C1:C5)),LEN(C1:C5),0),1)
The value jumped over appears in cell C7.
Let us examine the formula, starting from the inner elements and working outward. The LEN function returns the length of each of the items in the cell range C1:C5. The MAX function calculates the largest value among those items, which corresponds to the longest text string, which is in cell C3.
Here's where things get a little complex. The MATCH function calculates the offset (the relative position) of the cell that contains the longest text string. To do that, it requires three arguments: a lookup value, a lookup array, and a match type. The MATCH function searches the lookup array for the specified lookup value. In this case, the lookup value is the longest text string:
(MAX(LEN(C1:C5))
and that string resides in this array:
LEN(C1:C5)
The match type argument is 0. The match type can consist of a 1, 0, or 1 value. If you specify 1, MATCH returns the largest value that is less than or equal to the lookup value. If you specify 0, MATCH returns the first value exactly equal to the lookup value. If you specify 1, MATCH finds the smallest value that is greater than or equal to the specified lookup value. If you omit a match type, Excel assumes 1.
Finally, the INDEX function takes these arguments: an array, and a row and column number within that array. The cell range C1:C5 provides the array, the MATCH function provides the cell address, and the final argument (1) specifies that the value comes from the first column in the array.
For more information about the functions discussed here, see Help in Excel.
Top of Page
Putting advanced array formulas to work
This section provides examples of advanced array formulas.
Sum a range that contains error values
The SUM function in Excel does not work when you try to sum a range that contains an error value, such as #N/A. This example shows you how to sum the values in a range named Data that contains errors.
=SUM(IF(ISERROR(Data),"",Data))
The formula creates a new array that contains the original values minus any error values. Starting from the inner functions and working outward, the ISERROR function searches the cell range (Data) for errors. The IF function returns a specific value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE. In this case, it returns empty strings ("") for all error values because they evaluate to TRUE, and it returns the remaining values from the range (Data) because they evaluate to FALSE, meaning that they don't contain error values. The SUM function then calculates the total for the filtered array.
Count the number of error values in a range
This example is similar to the previous formula, but it returns the number of error values in a range named Data instead of filtering them out:
=SUM(IF(ISERROR(Data),1,0))
This formula creates an array that contains the value 1 for the cells that contain errors and the value 0 for the cells that don't contain errors. You can simplify the formula and achieve the same result by removing the third argument for the IF function, like so:
=SUM(IF(ISERROR(Data),1))
If you don't specify the argument, the IF function returns FALSE if a cell does not contain an error value. You can simplify the formula even more:
=SUM(IF(ISERROR(Data)*1))
This version works because TRUE*1=1 and FALSE*1=0.
Sum values based on conditions
You may need to sum values based on conditions. For example, this array formula sums just the positive integers in a range named Sales:
=SUM(IF(Sales>0,Sales))
The IF function creates an array of positive values and false values. The SUM function essentially ignores the false values because 0+0=0. The cell range that you use in this formula can consist of any number of rows and columns.
You can also sum values that meet more than one condition. For example, this array formula calculates values greater than 0 and less than or equal to 5:
=SUM((Sales>0)*(Sales<=5)*(Sales))
Keep in mind that this formula returns an error if the range contains one or more nonnumeric cells.
You can also create array formulas that use a type of OR condition. For example, you can sum values that are less than 5 and greater than 15:
=SUM(IF((Sales<5)+(Sales>15),Sales))
The IF function finds all values smaller than 5 and greater than 15 and then passes those values to the SUM function.
Important You cannot use the AND and OR functions in array formulas directly because those functions return a single result, either TRUE or FALSE, and array functions require arrays of results. You can work around the problem by using the logic shown in the previous formula. In other words, you perform math operations, such as addition or multiplication, on values that meet the OR or AND condition.
Compute an average that excludes zeros
This example shows you how to remove zeros from a range when you need to average the values in that range. The formula uses a data range named Sales:
=AVERAGE(IF(Sales<>0,Sales))
The IF function creates an array of values that do not equal 0 and then passes those values to the AVERAGE function.
Count the number of differences between two ranges of cells
This array formula compares the values in two ranges of cells named MyData and YourData and returns the number of differences between the two. If the contents of the two ranges are identical, the formula returns 0. To use this formula, the cell ranges must be the same size and of the same dimension:
=SUM(IF(MyData=YourData,0,1))
The formula creates a new array of the same size as the ranges that you are comparing. The IF function fills the array with the value 0 and the value 1 (0 for mismatches and 1 for identical cells). The SUM function then returns the sum of the values in the array.
You can simplify the formula like this:
=SUM(1*(MyData<>YourData))
Like the formula that counts error values in a range, this formula works because TRUE*1=1, and FALSE*1=0.
Find the location of the maximum value in a range
This array formula returns the row number of the maximum value in a singlecolumn range named Data:
=MIN(IF(Data=MAX(Data),ROW(Data),""))
The IF function creates a new array that corresponds to the Data range. If a corresponding cell contains the maximum value in the range, the array contains the row number. Otherwise, the array contains an empty string (""). The MIN function uses the new array as its second argument and returns the smallest value, which corresponds to the row number of the maximum value in Data. If the Data range contains identical maximum values, the formula returns the row of the first value.
If you want to return the actual cell address of a maximum value, use this formula:
=ADDRESS(MIN(IF(Data=MAX(Data),ROW(Data),"")),COLUMN(Data))
Top of Page
Excel > Formula and name basics > Creating formulas
Create or delete a formula
Excel 2007
Formulas (formula: A sequence of values, cell references, names, functions, or operators in a cell that together produce a new value. A formula always begins with an equal sign (=).) are equations that perform calculations on values in your worksheet. A formula always starts with an equal sign (=).
You can create a simple formula by using constants (constant: A value that is not calculated. For example, the number 210 and the text "Quarterly Earnings" are constants. An expression, or a value resulting from an expression, is not a constant.) and calculation operators (operator: A sign or symbol that specifies the type of calculation to perform within an expression. There are mathematical, comparison, logical, and reference operators.). For example, the formula =5+2*3, multiplies two numbers and then adds a number to the result. Microsoft Office Excel follows the standard order of mathematical operations. In the preceding example, the multiplication operation (2*3) is performed first, and then 5 is added to its result.
You can also create a formula by using a function (function: A prewritten formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that perform lengthy or complex calculations.). For example, the formulas =SUM(A1:A2) and SUM(A1,A2) both use the SUM function to add the values in cells A1 and A2.
Depending on the type of formula that you create, a formula can contain any or all of the following parts.
Functions A function, such as PI(), starts with an equal sign (=), and you can enter arguments (argument: The values that a function uses to perform operations or calculations. The type of argument a function uses is specific to the function. Common arguments that are used within functions include numbers, text, cell references, and names.) for the function within its parentheses. Each function has a specific argument syntax.
Cell references You can refer to data in worksheet cells by including cell references in the formula. For example, the cell reference A2 returns the value of that cell or uses that value in the calculation.
Constants You can also enter constants, such as numbers (such as 2) or text values, directly into a formula.
Operators Operators are the symbols that are used to specify the type of calculation that you want the formula to perform. For example, the ^ (caret) operator raises a number to a power, and the * (asterisk) operator multiplies numbers.
To achieve the calculation result that you want, you can use a single function, nested functions, or arrays (array: Used to build single formulas that produce multiple results or that operate on a group of arguments that are arranged in rows and columns. An array range shares a common formula; an array constant is a group of constants used as an argument.) that calculate single or multiple results. You can delete any formula when it's no longer needed.
What do you want to do?
Create a simple formula by using constants and calculation operators
Create a formula by using cell references and names
Create a formula by using a function
Create a formula by using nested functions
Create an array formula that calculates a single result
Create an array formula that calculates multiple results
Delete a formula
Learn tips and tricks about creating formulas
Avoid common errors when creating formulas
Create a simple formula by using constants and calculation operators

Click the cell in which you want to enter the formula.

Type = (equal sign).

To enter the formula, do one of the following:

Type the constants and operators that you want to use in the calculation.
Example formula

What it does

=5+2

Adds 5 and 2

=52

Subtracts 2 from 5

=5/2

Divides 5 by 2

=5*2

Multiplies 5 times 2

=5^2

Raises 5 to the 2nd power



Click the cell that contains the value that you want to use in the formula, type the operator that you want to use, and then click another cell that contains a value.
Example formula

What it does

=A1+A2

Adds the values in cells A1 and A2

=A1A2

Subtracts the value in cell A2 from the value in A1

=A1/A2

Divides the value in cell A1 by the value in A2

=A1*A2

Multiplies the value in cell A1 times the value in A2

=A1^A2

Raises the value in cell A1 to the exponential value specified in A2


Tip You can enter as many constants and operators as you need to achieve the calculation result that you want.

Press ENTER.
Top of Page
Create a formula by using cell references and names
The example formulas at the end of this section contain relative references (relative reference: In a formula, the address of a cell based on the relative position of the cell that contains the formula and the cell referred to. If you copy the formula, the reference automatically adjusts. A relative reference takes the form A1.) to and names (name: A word or string of characters that represents a cell, range of cells, formula, or constant value. Use easytounderstand names, such as Products, to refer to hard to understand ranges, such as Sales!C20:C30.) of other cells. The cell that contains the formula is known as a dependent cell when its value depends on the values in other cells. For example, cell B2 is a dependent cell if it contains the formula =C2.

Click the cell in which you want to enter the formula.

In the formula bar (formula bar: A bar at the top of the Excel window that you use to enter or edit values or formulas in cells or charts. Displays the constant value or formula stored in the active cell.) , type = (equal sign).

Do one of the following:

To create a reference, select a cell, a range of cells, a location in another worksheet, or a location in another workbook. This behavior is called semiselection. You can drag the border of the cell selection to move the selection, or drag the corner of the border to expand the selection.
The first cell reference is B3, the color is blue, and the cell range has a blue border with square corners.
The second cell reference is C3, the color is green, and the cell range has a green border with square corners.
Note If there is no square corner on a colorcoded border, the reference is to a named range.


To enter a reference to a named range, press F3, select the name in the Paste name box, and click OK.
Example formula

What it does

=C2

Uses the value in the cell C2

=Sheet2!B2

Uses the value in cell B2 on Sheet2

=AssetLiability

Subtracts the value in a cell named Liability from the value in a cell named Asset


Press ENTER.
For more information, see Create or change a cell reference.
Top of Page
Create a formula by using a function

Click the cell in which you want to enter the formula.

To start the formula with the function, click Insert Function on the formula bar .

Select the function that you want to use.
You can enter a question that describes what you want to do in the Search for a function box (for example, "add numbers" returns the SUM function), or browse from the categories in the Or Select a category box.
Tip For a list of available functions, see List of worksheet functions (by category).

Enter the arguments.
Tip To enter cell references as an argument, click Collapse Dialog (which temporarily hides the dialog box), select the cells on the worksheet, and then press Expand Dialog .
Example formula

What it does

=SUM(A:A)

Adds all numbers in column A

=AVERAGE(A1:B4)

Averages all numbers in the range


After you complete the formula, press ENTER.
Tip To summarize values quickly, you can also use AutoSum. On the Home tab, in the Editing group, click AutoSum, and then click the function that you want.
Top of Page
Create a formula by using nested functions
Nested functions use a function as one of the arguments of another function. You can nest up to 64 levels of functions. The following formula sums a set of numbers (G2:G5) only if the average of another set of numbers (F2:F5) is greater than 50. Otherwise, it returns 0.
The AVERAGE and SUM functions are nested within the IF function.

Click the cell in which you want to enter the formula.

To start the formula with the function, click Function Wizard on the formula bar .

Select the function that you want to use.
You can enter a question that describes what you want to do in the Search for a function box (for example, "add numbers" returns the SUM function), or browse from the categories in the Or Select a category box.
Tip For a list of available functions, see List of worksheet functions (by category).

To enter the arguments, do one or more of the following:

To enter cell references as an argument, click Collapse Dialog next to the argument you want (which temporarily hides the dialog box), select the cells on the worksheet, and then press Expand Dialog .

To enter another function as an argument, enter the function in the argument box that you want. For example, you can add SUM(G2:G5) in the Value_if_true edit box of the IF function.

The parts of the formula displayed in the Function Arguments dialog box reflect the function that you selected in the previous step. For example, if you clicked IF, the Function arguments dialog box displays the arguments for the IF function.
Top of Page
Create an array formula that calculates a single result
You can use an array formula (array formula: A formula that performs multiple calculations on one or more sets of values, and then returns either a single result or multiple results. Array formulas are enclosed between braces { } and are entered by pressing CTRL+SHIFT+ENTER.) to perform several calculations to generate a single result. This type of array formula can simplify a worksheet model by replacing several different formulas with a single array formula.

Click the cell in which you want to enter the array formula.

Enter the formula that you want to use.
Tip Array formulas use standard formula syntax. They all begin with an equal sign, and you can use any of the builtin Excel functions in your array formulas.
For example, the following formula calculates the total value of an array of stock prices and shares, without using a row of cells to calculate and display the total values for each stock.
Array formula that produces a single result
When you enter the formula {=SUM(B2:C2*B3:C3)} as an array formula, Excel multiples the number of shares by the price for each stock (500*10 and 300*15), and then adds the results of those calculations together to get a total value of 9500.

Press CTRL+SHIFT+ENTER.
Excel automatically inserts the formula between { } (a pair of opening and closing braces).
Note Manually typing braces around a formula will not convert it into an array formula — you must press CTRL+SHIFT+ENTER to create an array formula.
Important Any time you edit the array formula, the braces ({ }) disappear from the array formula, and you must press CTRL+SHIFT+ENTER again to incorporate the changes into an array formula and to add the braces.
Top of Page
Create an array formula that calculates multiple results
Some worksheet functions return arrays of values, or require an array of values as an argument. To calculate multiple results by using an array formula, you must enter the array into a range of cells that has the same number of rows and columns as the array arguments have.

Select the range of cells in which you want to enter the array formula.

Enter the formula that you want to use.
Tip Array formulas use standard formula syntax. They all begin with an equal sign, and you can use any of the builtin Excel functions in your array formulas.
For example, given a series of three sales figures (column B) for a series of three months (column A), the TREND function determines the straightline values for the sales figures. To display all of the results of the formula, it is entered into three cells in column C (C1:C3).
Array formula that produces multiple results
When you enter the formula =TREND(B1:B3,A1:A3) as an array formula, it produces three separate results (22196, 17079, and 11962), based on the three sales figures and the three months.

Press CTRL+SHIFT+ENTER.
Excel automatically inserts the formula between { } (a pair of opening and closing braces).
Note Manually typing braces around a formula will not convert it into an array formula — you must press CTRL+SHIFT+ENTER to create an array formula.
Important Any time you edit the array formula, the braces ({ }) disappear from the array formula, and you must press CTRL+SHIFT+ENTER again to incorporate the changes into an array formula and to add the braces.
Top of Page
Delete a formula
When you delete a formula, the resulting values of the formula is also deleted. However, you can instead remove the formula only and leave the resulting value of the formula displayed in the cell.

To delete formulas along with their resulting values, do the following:

Select the cell or range of cells that contains the formula.

Press DELETE.

To delete formulas without removing their resulting values, do the following:

Select the cell or range of cells that contains the formula.
If the formula is an array formula, select the range of cells that contains the array formula.
How to select a range of cells that contains the array formula



Click a cell in the array formula.

On the Home tab, in the Editing group, click Find & Select, and then click Go To.

Click Special.

Click Current array.

On the Home tab, in the Clipboard group, click Copy .
Keyboard shortcut You can also press CTRL+C.


On the Home tab, in the Clipboard group, click the arrow below Paste , and then click Paste Values.
Top of Page
Learn tips and tricks about creating formulas
Quickly copy formulas You can quickly enter the same formula into a range of cells. Select the range that you want to calculate, type the formula, and then press CTRL+ENTER. For example, if you type =SUM(A1:B1) in range C1:C5, and then press CTRL+ENTER, Excel enters the formula in each cell of the range, using A1 as a relative reference.
Use Formula Autocomplete To make it easier to create and edit formulas and minimize typing and syntax errors, use Formula Autocomplete. After you type an = (equal sign) and beginning letters (the beginning letters act as a display trigger), Excel displays a dynamic list of valid functions and names below the cell. After you insert the function or name into the formula by using an insert trigger (pressing TAB or doubleclicking the item in the list), Excel displays any appropriate arguments. As you fill out the formula, typing a comma can also act as a display trigger — Excel may display additional arguments. You can insert additional functions or names into your formula and, as you type their beginning letters, Excel again displays a dyamic list from which you can choose.
Use Function ScreenTips If you are familiar with the arguments of a function, you can use the function ScreenTip that appears after you type the function name and an opening parenthesis. Click the function name to view the Help topic on the function, or click an argument name to select the corresponding argument in your formula.
Top of Page
Avoid common errors when creating formulas
The following table summarizes some of the the most common errors that you can make when entering a formula and how to correct those errors:
Make sure that you…

More information

Match all open and close parentheses

Make sure that all parentheses are part of a matching pair. When you create a formula, Excel displays parentheses in color as they are entered.

Use a colon to indicate a range

When you refer to a range of cells, use a colon (:) to separate the reference to the first cell in the range and the reference to the last cell in the range. For example, A1:A5.

Enter all required arguments

Some functions have required arguments. Also, make sure that you have not entered too many arguments.

Nest no more than 64 functions

You can enter, or nest, no more than 64 levels of functions within a function.

Enclose other sheet names in single quotation marks

If the formula refers to values or cells on other worksheets or workbooks, and the name of the other workbook or worksheet contains a nonalphabetical character, you must enclose its name within single quotation marks ( ' ).

Include the path to external workbooks

Make sure that each external reference (external reference: A reference to a cell or range on a sheet in another Excel workbook, or a reference to a defined name in another workbook.) contains a workbook name and the path to the workbook.

Enter numbers without formatting

Do not format numbers as you enter them in formulas. For example, even if the value that you want to enter is $1,000, enter 1000 in the formula.

Top of Page
See Also
Excel > Formula and name basics > Creating formulas
Use Formula AutoComplete
To make it easier to create and edit formulas and minimize typing and syntax errors, use Formula AutoComplete. After you type an = (equal sign) and beginning letters or a display trigger, Microsoft Office Excel displays below the cell a dynamic dropdown list of valid functions, names, and text strings that match the letters or trigger. You can then insert an item in the dropdown list into the formula by using an insert trigger.
Type the = (equal sign) and beginning letters or a display trigger to start Formula AutoComplete.
As you type, a scrollable list of valid items is displayed with the closest match highlighted.
Icons represent the type of entry, such as a function or table reference.
Detailed ScreenTips help you make the best choice.
What do you want to do?
Control the dropdown list by using display triggers
Navigate the Formula AutoComplete dropdown list by using keys
Enter an item from the dropdown list by using an insert trigger
Turn Formula AutoComplete on or off
Control the dropdown list by using display triggers
The following table summarizes how to dynamically control the display of items in the Formula AutoComplete dropdown list.
To display

Type this

Excel and userdefined function names

A letter or beginning letters anywhere a function can be entered.
Example: Su

Function arguments

(No display trigger).
Type the argument, such as a number or cell reference, or use a display trigger, such as beginning letters or an [ (opening bracket).
Example: SUM(5, A2, [
For each subsequent argument, type a comma and then the argument or another display trigger.
Note The following functions have arguments with enumerated constants that automatically display in the dropdown list: CELL, FV, HLOOKUP, MATCH, PMT, PV, RANK, SUBTOTAL, and VLOOKUP.

Defined names and table names

A letter or beginning letters where that name can be entered.
Example: Ann

Table column specifiers and special item specifiers ([#All], [#Data], [#Headers], [#Totals], [#ThisRow])

One or more of the following:

[ (opening bracket) immediately after the table name.
Example: AnnualSummary[

, (comma) immediately after a special item.
Example: =AnnualSummary[#All],

: (colon) immediately after a column name.
Example: AnnualSummary[Sales:
Note If the cell is in a table, the table name is optional. For example, the following formulas would be the same:
=[Sales]/[Costs]
=AnnualSummary[Sales]/AnnualSummary[Costs]

Connection names in Cube functions

" (opening quotation mark) immediately after the opening parenthesis of a Cube function name.
Example: CUBEMEMBER("
Note Only OLAP connections stored in the current workbook are listed.

Multidimensional expressions (MDX) text strings in Cube functions

One or more of the following:

" (opening quotation mark) immediately after the comma for an argument.
Example: CUBEMEMBER("SalesCubeData","

. (period) immediately after a closing bracket.
Example: CUBEMEMBER("SalesCubeData","[Customers].
Example: CUBEMEMBER("SalesCubeData","[Customers].[Mexico].

( (opening parenthesis) immediately after an opening quotation mark for an MDX text string to indicate the beginning of a tuple.
Example: CUBEVALUE("SalesCubeData","(

, (comma) immediately after a closing bracket in an MDX text string to indicate the second part of a tuple.
Example: CUBEVALUE("SalesCubeData","([Customers].[Mexico],

{ (opening brace) immediately after an opening quotation mark for an MDX text string to indicate the beginning of a set expression.
Example: CUBEVALUE("SalesCubeData","{
Notes

You must be connected to an OLAP data source to enter an MDX text string using Formula AutoComplete.

If a caption is defined, it is displayed in a ScreenTip to help confirm the choice.

If an MDX text string is ambiguous, then a unique member name is still entered but you must decide if the correct one was entered. For example, if there are two values for the following MDX text string:
CUBEMEMBER("SalesCubeData","[Customers].[Mexico].[Hidalgo].[Dora N. Boots]
One of the following values would be entered:
[Customers].[Name].&[54342]
[Customers].[Name].&[34297]
If the one entered is not what you want, you would delete it, and then select the other one.

Microsoft SQL Server Analysis Services function names, such as "Children", "Parent", or "Crossjoin" are not displayed in the dropdown list, but you can still type them.

Notes

At any time that you are using Formula AutoComplete, you can type what you want to finish the formula.

You can use Formula AutoComplete in the middle of an existing nested function or formula. The text immediately before the insertion point is used to display values in the dropdown list, and all of the text after the insertion point remains unchanged.

Defined names that you create for enumerated constants, such as the ones used in the SUBTOTAL function, and Cube function connections do not display in the AutoComplete dropdown list, but you can still type them.
Top of Page
Navigate the Formula AutoComplete dropdown list by using keys
The following table summarizes the keys that you can use to navigate the Formula AutoComplete dropdown list.
To

Press

Move the insertion point one character to the left.

LEFT ARROW

Move the insertion point one character to the right.

RIGHT ARROW

Move the selection up one item.

UP ARROW

Move the selection down one item.

DOWN ARROW

Select the last item.

END

Select the first item.

HOME

Move down one page and select a new item.

PAGE DOWN

Move up one page and select a new item.

PAGE UP

Close the dropdown list.

ESCAPE (or click another cell)

Turn on or off Formula AutoComplete.

ALT+DOWN ARROW

Top of Page
Enter an item from the dropdown list by using an insert trigger
Important As you are typing a formula, even after using an insert trigger, don't forget to type the closing parenthesis for a function, closing bracket for a table reference, or closing quotation mark for an MDX text string.

To insert the selected item into the formula and put the insertion point directly after it, press TAB, or doubleclick the item.
Top of Page
Turn Formula AutoComplete on or off

Click the Microsoft Office Button , click Excel Options, and then click the Formulas category.

Under Working with formulas, select or clear Formula AutoComplete.
Tip You can also press ALT+DOWN ARROW.
Top of Page
Excel > Formula and name basics > Creating formulas
Nest a function within a function
Excel 2007
Nested functions use a function as one of the arguments of another function. You can nest up to 64 levels of functions. The following formula sums a set of numbers (G2:G5) only if the average of another set of numbers (F2:F5) is greater than 50. Otherwise it returns 0.
The AVERAGE and SUM functions are nested within the IF function.

Click the cell in which you want to enter the formula.

To start the formula with the function, click Function Wizard on the formula bar (formula bar: A bar at the top of the Excel window that you use to enter or edit values or formulas in cells or charts. Displays the constant value or formula stored in the active cell.) .

Select the function you want to use. You can enter a question that describes what you want to do in the Search for a function box (for example, "add numbers" returns the SUM function), or browse from the categories in the Or Select a category box.

Enter the arguments (argument: The values that a function uses to perform operations or calculations. The type of argument a function uses is specific to the function. Common arguments that are used within functions include numbers, text, cell references, and names.).

To enter cell references as an argument, click Collapse Dialog next to the argument that you want (which temporarily hides the dialog box), select the cells on the worksheet, and then click Expand Dialog .

To enter another function as an argument, enter the function in the argument box that you want. For example, you can add SUM(G2:G5) in the Value_if_true edit box of the IF function.

The parts of the formula displayed in the Function Arguments dialog box reflect the function that you selected in the previous step. For example, if you clicked IF, Function arguments displays the arguments for the IF function.
Top of Page
See Also
Excel > Formula and name basics > Creating formulas
Move or copy a formula
Excel 2007
It's important to be aware of what can happen to cell references (cell reference: The set of coordinates that a cell occupies on a worksheet. For example, the reference of the cell that appears at the intersection of column B and row 3 is B3.), whether they are absolute (absolute cell reference: In a formula, the exact address of a cell, regardless of the position of the cell that contains the formula. An absolute cell reference takes the form $A$1.) or relative (relative reference: In a formula, the address of a cell based on the relative position of the cell that contains the formula and the cell referred to. If you copy the formula, the reference automatically adjusts. A relative reference takes the form A1.), when you move a formula by cutting and pasting it, or copy a formula by copying and pasting it.

When you move a formula, the cell references within the formula do not change no matter what type of cell reference that you use.

When you copy a formula, the cell references may change based on the type of cell reference that you use.
What do you want to do?
Move a formula
Copy a formula
Move a formula

Select the cell that contains the formula that you want to move.

On the Home tab, in the Clipboard group, click Cut.
You can also move formulas by dragging the border of the selected cell to the upperleft cell of the paste area. Any existing data is replaced.

Do one of the following:

To paste the formula and any formatting, on the Home tab, in the Clipboard group, click Paste.

To paste the formula only, on the Home tab, in the Clipboard group, click Paste, click Paste Special, and then click Formulas.
Top of Page
Copy a formula

Select the cell that contains the formula that you want to copy.

On the Home tab, in the Clipboard group, click Copy.

Do one of the following:

To paste the formula and any formatting, on the Home tab, in the Clipboard group, click Paste.

To paste the formula only, on the Home tab, in the Clipboard group, click Paste, click Paste Special, and then click Formulas.
Note You can paste only the formula results. On the Home tab, in the Clipboard group, click Paste, click Paste Special, and then click Values.

Verify that the cell references in the formula produce the result that you want. If necessary, switch the type of reference by doing the following:

The following table summarizes how a reference type updates if a formula that contains the reference is copied two cells down and two cells to the right.
For a formula being copied:

If the reference is:

It changes to:


$A$1 (absolute column and absolute row)

$A$1

A$1 (relative column and absolute row)

C$1

$A1 (absolute column and relative row)

$A3

A1 (relative column and relative row)

C3

Note You can also copy formulas into adjacent cells by using the fill handle (fill handle: The small black square in the lowerright corner of the selection. When you point to the fill handle, the pointer changes to a black cross.) . After verifying that the cell references in the formula produce the result that you want in step 4, select the cell that contains the copied formula, and then drag the fill handle over the range that you want to fill.
Top of Page
See Also
Excel > Formula and name basics > Creating formulas
Resize the formula or name box in the formula bar
Excel 2007
To make it easier to view and edit a long formula (formula: A sequence of values, cell references, names, functions, or operators in a cell that together produce a new value. A formula always begins with an equal sign (=).) or large amount of text in a cell, you can adjust the size of the formula box in the formula bar (formula bar: A bar at the top of the Excel window that you use to enter or edit values or formulas in cells or charts. Displays the constant value or formula stored in the active cell.). To accommodate long names (name: A word or string of characters in Excel that represents a cell, range of cells, formula, or constant value.), you can also resize the name box (Name box: Box at left end of the formula bar that identifies the selected cell, chart item, or drawing object. To name a cell or range, type the name in the Name box and press ENTER. To move to and select a named cell, click its name in the Name box.) in the formula bar. The worksheet and formula bar work in tandem so that contents of both do not overlap.
Adjust the width of the name box left or right.
Adjust the height of the formula box up or down.
What do you want to do?
Resize the formula box
Resize the name box
Resize the formula box
Do one or more of the following:

To switch between expanding the formula box to three or more lines or collapsing it to one line, click the chevron button at the end of the formula bar. You can also press CTRL+SHIFT+U.

To precisely adjust the height of the formula box, hover over the bottom of the formula box until the pointer changes to a vertical double arrow , drag the vertical double arrow up or down to where you want it, and then either click the vertical double arrow or press ENTER.

To automatically fit the formula box to the number of lines of text in the active cell up to the maximum height, hover over the formula box until the pointer changes to a vertical double arrow , and then doubleclick the vertical double arrow.
Notes

You can resize the formula box to a maximum size so that only one worksheet row is visible.

When you resize the formula box, the active cell always stays visible on the worksheet.

A scroll bar in the formula box means that there is more text to view. To activate the scroll bars, click the cell or the formula box.

By default, when you enter text in a cell, it is one line of text with no line breaks, but the text wraps when displayed in the formula bar. If you manually insert a line break in the cell by pressing ALT+ENTER, the line break also displays in the formula bar.
Top of Page
Resize the name box

To adjust the width of the name box either smaller or larger, hover between the name box and the formula box until the pointer changes to a horizontal double arrow , drag the horizontal double arrow left or right to where you want it, and then either click the horizontal double arrow or press ENTER.
Note The maximum width of the name box is half of the width of the worksheet.
Top of Page
Excel > Formula and name basics > Creating formulas
Select cells that contain formulas
Excel 2007
When you check, update, or audit formulas in a workbook, you can use the Go To Special dialog box to conveniently select one or more cells that contain a formula, or select just the cells of an array formula that calculates multiple results.
What do you want to do?
Select a range of cells that contains nonarray formulas
Select a range of cells that contains an array formula that calculates multiple results
Select a range of cells that contains nonarray formulas

Do one of the following:

On the Home tab, in the Editing group, click the arrow next to Find & Select, and then click Go To Special.
The Go To Special dialog box is displayed.

Click Formulas.

Select or clear one or more of the following check boxes to indicate the type of formula that you want to check based on the formula result:

Numbers A numeric value.

Text A text value.

Logicals A TRUE or FALSE value.

Errors An error value, including #DIV/0!, #N/A, #NAME?, #NULL!, #NUM!, #REF!, and #VALUE!.
If one or more selected cells contain formulas based on the formula result that you selected in step 4, those cells are highlighted, otherwise Microsoft Office Excel 2007 displays a message that no cells were found.
Top of Page
Select a range of cells that contains an array formula that calculates multiple results

Click a cell that contains an array formula (array formula: A formula that performs multiple calculations on one or more sets of values, and then returns either a single result or multiple results. Array formulas are enclosed between braces { } and are entered by pressing CTRL+SHIFT+ENTER.) that calculates multiple results.
For more information about functions that calculate multiple results, see Create or delete a formula, TREND, and GROWTH.

On the Home tab, in the Editing group, click the arrow next to Find & Select, and then click Go To Special.
The Go To Special dialog box is displayed.

Click Current array.
If cells contain the array formula based on the cell that you selected in step 1, those cells are highlighted, otherwise Office Excel 2007 displays a message that no cells were found.
Top of Page
See Also
Excel > Formula and name basics > Creating formulas
Use Equation Editor in Excel
Excel 2007
To document a formula on a worksheet, you can insert or edit an equation as an object by using Microsoft Equation Editor. You build the equation by selecting symbols from the Equation toolbar (toolbar: A bar with buttons and options that you use to carry out commands. To display a toolbar, press ALT and then SHIFT+F10.) and by typing variables and numbers. From the top row of the Equation toolbar, you can choose from more than 150 mathematical symbols. From the bottom row, you can choose from a variety of templates or frameworks that contain symbols, such as fractions, integrals, and summations.
What do you want to do?
Insert an equation with Equation Editor
Edit an equation in Equation Editor
Insert an equation with Equation Editor

Click where you want to insert the equation.

On the Insert tab, in the Text group, click Object.

In the Object dialog box, click the Create New tab.

In the Object type box, click Microsoft Equation 3.0.
If Equation Editor is not available, you may need to install it.
Install Equation Editor


Exit all programs.

Click Add or Remove Programs in Control Panel.

In the Currently installed programs box, click Microsoft Office 2007 or Microsoft Office Excel 2007, depending on whether you installed Excel as part of Office or as an individual program, and then click Change.

On the Change your installation of Microsoft Office 2007. screen, click Add or Remove Features, and then click Continue.

On the Installation Options tab, click the expand indicator (+) next to Office Tools.

Click the arrow next to Equation Editor, and then click Run from My Computer.

Click Continue.

After the Equation Editor installation is complete, restart Office Excel 2007.

In the Object dialog box, click OK.

Use options on the Equation toolbar to edit the equation.
If you need help, click Equation Editor Help Topics on the Help menu.

To return to Excel, click on an empty cell.
Top of Page
Edit an equation in Equation Editor

Doubleclick the equation object that you want to edit.

Use options on the Equation toolbar to edit the equation.
If you need help, click Equation Editor Help Topics on the Help menu.

To return to Excel, click an empty cell.
Top of Page