Sie sind auf Seite 1von 39

# Type of Formula

Example

Conditional

## Create conditional formulas

Check if a number is greater than or less than another number
Display or hide zero values
Hide error values and error indicators in a cell
Combine two or more columns by using a function
Combine text and numbers

Lookup

## Date and Time

Calculate the difference between two dates
Calculate the difference between two times
Count days before a date
Show dates as the day of the week
Insert the current date and time in a cell
Insert Julian dates

Financial

## Calculate a running balance

Calculate a compound annual growth rate (CAGR)

Statistical

## Calculate the average of a group of numbers

Calculate the median of a group of numbers
Calculate the mode of a group of numbers

Math

Subtract numbers
Multiply numbers
Divide numbers
Calculate percentages
Round a number
Raise a number to a power
Calculate the smallest or largest number in a range

## Common Formulas > Financial Formulas

Let's say you want to see the number of products in an inventory list grow as you add
products each day. Use a running total (also called a running count) to watch the number of
items in a spreadsheet add up as you enter new items. To calculate a running total, use the
following procedure.
1. Set up a worksheet like the following example.

Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1. Create a blank workbook or worksheet.
2. Select the example in the Help topic.
Note Do not select the row or column headers.

## Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return
the results, press CTRL+` (grave accent), or on the Tools menu, point to
Formula Auditing, and then click Formula Auditing Mode.
A
B
C
1 Product
Description
Running total
2 Sandbox Sturdy but a bit worn
1
3 Beach toys Hardly used
=1+C2
4 Swing set Weathered, but still safe =1+C3
2. Click anywhere outside cell C4 to see the running total.
3. To maintain the running total, add a row for each new entry by doing the following:
1. Type the product and description into the empty rows directly below the
existing data.

For instance, if you were using the example above, you would type the
products into A5, A6, and so on, and the descriptions into B5, B6, and so on.
2. Extend the running total formula into the new rows by selecting the last cell in
the balance column and then double-clicking the fill handle (fill handle: The
small black square in the lower-right corner of the selection. When you point
to the fill handle, the pointer changes to a black cross.).
For instance, if you were using the example above, you would select cell C3
and then double-click its fill handle to extend the formula into all new rows
that contain products and descriptions.

Note A running total differs from a running balance, in which you watch the sum of values

## Calculate a running balanceHelp

Show All
Let's say you may want to see a running balance of items that you purchase so that
you don't exceed your spending limits. You can use a running balance to watch
values of items in cells add up as you enter new items and values over time. To
calculate a running balance, use the following procedure.
1. Set up a worksheet like the following example.

Example
The example may be easier to understand if you copy it to a blank
worksheet.
How to copy an example
1. Create a blank workbook or worksheet.
2. Select the example in the Help topic.
Note Do not select the row or column headers.

## Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that
return the results, press CTRL+` (grave accent), or on the Tools
menu, point to Formula Auditing, and then click Formula Auditing
Mode.
A
B
C
1 Deposits Withdrawals
Balance
2 \$1,000 \$625
=SUM(A2,-B2)
3 1000
740
=SUM(C2,A3,-B3)
2. Click anywhere outside cell C3 to see the calculated total.
3. To maintain the running balance, add a row for each new entry by doing the
following:
1. Type the amounts of your deposits and withdrawals into the empty
rows directly below the existing data.
For instance, if you were using the example above, you would type
the deposits into A4, A5, and so on, and the withdrawals into B4, B5,
and so on.
2. Extend the running balance formula into the new rows by selecting
the last cell in the balance column and then double-clicking the fill
handle (fill handle: The small black square in the lower-right corner
of the selection. When you point to the fill handle, the pointer
changes to a black cross.).
For instance, if you were using the example above, you would select
cell C3 and then double-click its fill handle to extend the formula into
all new rows that contain deposit and withdrawal values.
Note A running balance differs from a running total (also called a running count), in
which you watch the number of items in a worksheet add up as you enter new items.

## Combine two or more columns by using a

functionHelp
Show All
Let's say you have two or more columns of data that you want to combine in a single
column, such as the name and address of a person. To combine two or more columns,
use the CONCATENATE function. You can also use the CHAR function and an ASCII
code to insert a character, such as a line break, when you're combining the data.

Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1. Create a blank workbook or worksheet.
2. Select the example in the Help topic.
Note Do not select the row or column headers.

## Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the
results, press CTRL+` (grave accent), or on the Tools menu, point to Formula
Auditing, and then click Formula Auditing Mode.
Note To see the result without breaking the lines of the name or address, expand the
width of column A to at least 17.00 units or 124 pixels.

1
2

First name

Last name

Robert

Walters
Function

Description

C
D
E
F
Street
Zip
City State
code
4567
Buffalo NY 98052
Main St.

## Combines the last

name with the
words "The" and
"Family" and then
combines the
CHAR(10) is used
B2, " Family", CHAR(10),
C2, CHAR(10), D2, ", ", E2, " to insert a new line.
", F2)
Result:
The Walters Family
4567 Main St.
Buffalo, NY 98052

Function details
CONCATENATE
CHAR
ASCII character chart

## Change the case of text

Help
Show All

Let's say you want to convert text from uppercase to lowercase or from lowercase to proper
case to make it more readable. To change the case of text, use the UPPER, LOWER, or
PROPER functions.

Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1. Create a blank workbook or worksheet.
2. Select the example in the Help topic.
Note Do not select the row or column headers.

## Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the
results, press CTRL+` (grave accent), or on the Tools menu, point to Formula
Auditing, and then click Formula Auditing Mode.
A
Name
nancy Davolio
1
Formula
Description (Result)
2 =UPPER(A2) Changes text to all UPPERCASE (NANCY DAVOLIO)
=LOWER(A2) Changes text to all lowercase (nancy davolio)
=PROPER(A2) Changes text to Title Case (Nancy Davolio)

Function details
UPPER
LOWER
PROPER

## Combine text and numbers

Help

Text Formulas
Show All
Let's say you want to create a grammatically correct sentence from several columns of data
for a mass mailing or format numbers with text without affecting formulas that use those
numbers. There are several ways to combine text and numbers.
What do you want to do?
Display text before or after a number in a cell by using a number format
Combine text and numbers from different cells into the same cell by using a formula
Display text before or after a number in a cell by using a number format
If a column that you want to sort contains both numbers and text (such as Product #15,

Product #100, Product #200), it may not sort as expected. You can use a number format to
add text without changing the sorting behavior of the number.
Select the cells that you want to format.
On the Format menu, click Cells, and then click the Number tab.
In the Category list, click a category, and then click a built-in format that resembles the one
that you want.
In the Category list, click Custom.
In the Type box, edit the number format codes to create the format that you want.
To display both text and numbers in a cell, enclose the text characters in double quotation
marks (" ") or precede the numbers with a backslash (\). Editing a built-in format does not
remove the format.
To display
Use this code
12 as Product #12
"Product # " 0
12:00 as 12:00 AM EST
h:mm AM/PM "EST"
-12 as \$-12.00 Shortage and 12 as \$12.00 Surplus \$0.00 "Surplus";\$-0.00 "Shortage"
Top of Page
Combine text and numbers from different cells into the same cell by using a formula
To do this task, use the CONCATENATION and TEXT functions and the ampersand (&)
operator.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
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.
To switch between viewing the results and viewing the formulas that return the results, press
CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and then click
Formula Auditing Mode.
A
B
1 Salesperson
Sales
2 Buchanan
28
3 Dodsworth
40%
Formula
Description (Result)
Combines contents above into a phrase
=A2&" sold "&B2&" units."
(Buchanan sold 28 units)
=A3&" sold "&TEXT(B3,"0%")&" of Combines contents above into a phrase

## the total sales."

(Dodsworth sold 40% of the total sales)
=CONCATENATE(A2," sold ",B2,"
Combines contents above into a phrase
units.")
(Buchanan sold 28 units)
Note the use of the TEXT function in the formula. When you join a number to a string of text
by using the concatenation operator, use the TEXT function to format the number. The
formula uses the underlying value from the referenced cell (.4 in this example) not the
formatted value you see in the cell (40%). The TEXT function restores the number
formatting.
Functions details
CONCATENATE
TEXT

Help

## Combine text with a date or time

Let's say you want to create a grammatically correct sentence from several columns
of data for a mass mailing or format dates with text without affecting formulas that
use those dates. To combine text with a date or time, use the TEXT function and the
& (ampersand) operator.

Example

operators

## The example may be easier to understand if you copy

it to a blank worksheet.
How to copy an example
1. Create a blank workbook or worksheet.
2. Select the example in the Help topic.
Note Do not select the row or column headers.

## Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return
the results, press CTRL+` (grave accent), or on the Tools menu, point to
Formula Auditing, and then click Formula Auditing Mode.
A
Data
Billing Date
5-Jun-2007
1
Formula
2
="Statement date:
3
"&TEXT(A3, "d-mmm-yyyy")
=A2&" "&TEXT(A3, "mmmdd-yyyy")

Description (Result)
Combine text in a formula with a date
(Statement date: 5-Jun-2007)
Combine text and date from difference cells
into one cell (Billing Date Jun-05-2007)

Note To copy the number format code used in a cell into the formula, select the cell,
then click Cells on the Format menu. Click the Number tab. In the Category box,
click Custom, and then copy the contents of the Type box.

Functions details
TEXT

## Combine first and last names

Help

Show All
Let's say you want to create a single Full Name column by combining two other
columns, First Name and Last Name. To combine first and last names, use the
CONCATENATE function or the ampersand (&) operator.

Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1. Create a blank workbook or worksheet.
2. Select the example in the Help topic.
Note Do not select the row or column headers.

## Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the
results, press CTRL+` (grave accent), or on the Tools menu, point to Formula
Auditing, and then click Formula Auditing Mode.
A
1
First Name
2 Nancy
3 Andrew
Formula
=A2&" "&B2
=B3&", "&A3

B
Last Name
Davolio
Fuller
Description (Result)
Combines the names above, separated by a space
(Nancy Davolio)
Combines the names above, separated by a comma
(Fuller, Andrew)

=CONCATENATE(A2,"
",B2)

## Combines the names above, separated by a space

(Nancy Davolio)

Note To replace the formula with the results, select the cells, click Copy
Paste
, click Paste Options
, and then click Values Only.

, click

Function details
CONCATENATE

## Repeat a character in a cell

Help

Show All
Let's say you want to create a fixed column of special characters to format a report or

add periods to the end of a text column to provide a Tab leader similar to a table of
contents. To repeat a character in a cell, use the REPT function.

Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1. Create a blank workbook or worksheet.
2. Select the example in the Help topic.
Note Do not select the row or column headers.

## Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the
results, press CTRL+` (grave accent), or on the Tools menu, point to Formula
Auditing, and then click Formula Auditing Mode.
A
B
1
Formula
Description (Result)
2 =REPT(".",6) Repeat a period (.) 6 times (......)
3 =REPT("-",4) Repeat a dash (-) 4 times (----)

Function details
REPT

## Remove spaces and nonprinting characters from text

ASCII char
chart

Sometimes text values contain leading, trailing, or multiple embedded space characters
(Unicode character set (Unicode: A character encoding standard developed by the
Unicode Consortium. By using more than one byte to represent each character, Unicode
enables almost all of the written languages in the world to be represented by using a
single character set.) values 32 and 160), or non-printing characters (Unicode character
set values 0 to 31, 127, 129, 141, 143, 144, and 157). These characters can sometimes
cause unexpected results when you sort, filter, or search. For example, users may make
data from external sources may contain nonprinting characters embedded in the text.
Because these characters are not easily noticed, the unexpected results may be difficult
to understand. To remove these unwanted characters, you can use a combination of the
TRIM, CLEAN, and SUBSTITUTE functions.
The TRIM function removes spaces from text except for single spaces between words.
The CLEAN function removes all nonprintable characters from text. Both functions
were designed to work with 7-bit ASCII, which is a subset of the ANSI character
set (ANSI character set: An 8-bit character set used by Microsoft Windows that allows
you to represent up to 256 characters (0 through 255) by using your keyboard. The
ASCII character set is a subset of the ANSI set.). It's important to understand that the
first 128 values (0 to 127) in 7-bit ASCII represent the same characters as the first 128
values in the Unicode character set.
The TRIM function was designed to trim the 7-bit ASCII space character (value 32)
from text. In the Unicode character set, there is an additional space character called the
nonbreaking space character that has a decimal value of 160. This character is
commonly used in Web pages as the HTML entity, &nbsp;. By itself, the TRIM
function does not remove this nonbreaking space character.
The CLEAN function was designed to remove the first 32 non-printing characters in the
7 bit ASCII code (values 0 through 31) from text. In the Unicode character set, there are
additional nonprinting characters (values 127, 129, 141, 143, 144, and 157). By itself,
the CLEAN function does not remove these additional nonprinting characters.
To do this task, use the SUBSTITUTE function to replace the higher value Unicode
characters with the 7-bit ASCII characters for which the TRIM and CLEAN functions
were designed.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
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.

To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.
A
Data
BD 122
="XY"&CHAR(7)&"453"
BD 122
MN987
Formula
Description (Result)
Removes the trailing space
=TRIM(A2)
from the string "BD 122 "
(BD 112)
Removes the nonprinting
BEL character (ASCII
value of 7) from the string
=CLEAN(A3)
value created by the
expression
="XY"&CHAR(7)&"453"
(XY453)
1
Replaces each nonbreaking
2
space character (Unicode
3
value of 160) with a space
4
character (ASCII value of
5
32) by using the
=TRIM(SUBSTITUTE(A4,CHAR(160),CHAR(32))) SUBSTITUTE function,
and then removes the
embedded spaces from the
string " BD 122" (BD
112)
Replaces the nonprinting
DEL character (ASCII
value of 127) with a BEL
character (ASCII value of
=CLEAN(SUBSTITUTE(A5,CHAR(127),CHAR(7))) 7) by using the
SUBSTITUTE function,
and then removes the BEL
character from the string
"MN987" (MN987)
Function details
TRIM
CLEAN
SUBSTITUTE

## Remove characters from text

Help

Let's say you want to split a text column of phone numbers formatted as 999-999-9999
into three columns of numbers: area code, prefix, and number. There are several ways to
remove characters from text.
What do you want to do?
Remove a specified number of characters from the right or left side of text
Remove a text string from a worksheet by using the Replace command
Remove a specified number of characters from the right or left side of text
To do this task, use the LEN, LEFT, and RIGHT functions.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
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.
To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.
A
Data
Vitamin A
Vitamin B1
1
Formula
Description (Result)
2
Removes last two characters from contents of A2
3 =LEFT(A2, LEN(A2)-2)
(Vitamin)
=RIGHT(A3, LEN(A3)Removes first 8 characters from A3 (B1)
8)
Function details
LEN, LENB
LEFT, LEFTB
RIGHT, RIGHTB

Top of Page
Remove a text string from a worksheet by using the Replace command
Select the range (range: Two or more cells on a sheet. The cells in a range can be
If you want to search the entire worksheet, click any cell in the worksheet.
On the Edit menu, click Replace.
In the Find what box, enter the text or numbers that you want to search for or choose a
recent search from the Find what drop-down box.
Note You can use wildcard characters in your search criteria.
If you want to specify a format for your search, click Format and make your selections
in the Find Format dialog box.
Click Options to further define your search. For example, you can search for all of the
cells that contain the same kind of data, such as formulas.
In the Within box, you can select Sheet or Workbook to search a worksheet or an entire
workbook.
In the Replace with box, enter the replacement characters and specific formats if
necessary.
If you want to delete the characters in the Find what box, leave the Replace with box
blank.
Click Find Next.
To replace the highlighted occurrence or all occurrences of the found characters, click
Replace or Replace All.
Note To cancel a search in progress, press ESC.
Top of Page

Inserting
the current
Excel file
name in a
cell
Help
Applies to
Microsoft Excel 2002

## literally the word "filename", in quotation marks.

Insert the current file name, its full path, and the name of the active
worksheet (for example, C:\Excel\[test.xls]Testsheet)
Enter the following formula in the cell in which you want to display the current file
name with its full path and the name of the current worksheet:
=CELL("filename")

Insert the current file name and the name of the active worksheet (for
example, [text.xls]Testsheet)
Enter the following formula as an array formula to display the current file name and
active worksheet name:
=RIGHT(CELL("filename"),LEN(CELL("filename"))MAX(IF(NOT(ISERR(SEARCH("\",CELL("filename"),
ROW(1:255)))),SEARCH("\",CELL("filename"),ROW(1:255)))))

Notes

## To enter a formula as an array formula, press CTRL+SHIFT+ENTER.

The formula returns the name of the worksheet as long as the worksheet has been
saved at least once. If you use this formula on an unsaved worksheet, the formula
cell will remain blank until you save the worksheet.

## Insert the current file name only (for example, test.xls)

Enter the following formula to insert the name of the current file in a cell:
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

Note If you use this formula on an unsaved worksheet, you receive the error #VALUE!.
When you save the worksheet, the error is replaced by the filename.

## Split text among columns by using functions

Help

By
Applies to
Microsoft Office Excel 2003
Microsoft Excel 2002
Text functions are useful for manipulating strings in your data. For example, distributing the first,
middle, and last names from a cell into three separate columns.
This article demonstrates how to use combinations of the following text functions to extract and
copy name components into separate cells.
Function Syntax
LEFT
LEFT(text, num_chars)
MID
MID(text,start_num,num_chars)
RIGHT RIGHT(text, num_chars)
SEARCH SEARCH(find_text,within_text,start_num)
LEN
LEN(text)
Extracting name components
The key to distributing name components when using text functions is the position of each character
within a text string. The number of spaces in the full name and the position of the space within the
text string is important because it indicates the beginning or end of of name components in a string.
For example, in a cell that contains only a first and last name, the last name after the first instance of
a space. Some names in your list may contain a middle name, in which case the last name occurs
after the second instance of a space.
This article will show you how to extract various components from a variety of name formats. Click
an example name in the following table to see the formulas for extracting the components from that
name.
Note The formulas for each example may be easier to understand if you copy them to a blank
worksheet.
How?
Create a blank workbook or worksheet.
Select the example text and formulas in the table. However, do not select the row or column headers.

Press CTRL+C.
In the worksheet, select cell A1, and press CTRL+V.
To switch between viewing the results and viewing the formulas that return the results, press
CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and then click Formula
Auditing Mode.
Example name
Description
First
Middle
Last name
Suffix

1 Lisa Smith
2 John Q. Public
Janaina B. G.
3
Bueno
4 Kahn, Wendy Beth
Mary Kay D.
5
Andersen
Paula Barreto de
6
Mattos
7 James van Eaton

name
Lisa
John

name

No middle name
One middle initial

Q.

Smith
Public

Janaina

B. G.

Bueno

Beth

Kahn

Mary Kay D.

Paula

## Two-part last name

Last name and suffix first,
8 Bacon Jr., Dan K.
with comma
9 Gary Altman III With suffix
10 Mr. Ryan Ihrig
With prefix
11 Julie Taft-Rider
Hyphenated last name
Example 1: Lisa Smith

Barreto de
Mattos
van Eaton

James
Dan

Andersen

K.

Gary
Ryan
Julie

Bacon

Jr.

Altman
Ihrig
Taft-Rider

III

In this example, there are only two components: first name and last name. A single space separates
the two name components.
A
B
C
1 Full name First name
Last name
2 Lisa Smith =LEFT(A2, SEARCH(" ",A2,1)) =RIGHT(A2,LEN(A2)-SEARCH(" ",A2,1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name
The first name starts with the first character in the string (L) and ends at the fifth character (the
space). The formula returns 5 characters in A2, starting from the left.

## Use the SEARCH function to find the value for num_chars:

Search for the numeric position of the space in A2, starting from the left. (5)
Last name
The last name starts at the space, 5 characters from the right, and ends at the last character on the
right (h). The formula extracts 5 characters in A2, starting from the right.

Use the SEARCH and LEN functions to find the value for num_chars:

Search for the numeric position of the space in A2, starting from the left. (5)
Count the total length of the text string, and then subtract the number of characters from the left to
the first space, as found in Step 1. (10 - 5 = 5)
Example 2: John Q. Public
In this example, there are three components in the full name: first name, middle initial, and last
name. A space separates each name component.
A
B
C
D
First Name
Name
Middle Name (Q.)
Last Name (Public)
(John)
1
=MID(A2,SEARCH("
=LEFT(A2,
=RIGHT(A2,LEN(A2)2 John Q.
",A2,1)+1,SEARCH("
SEARCH("
SEARCH(" ",A2,SEARCH("
Public
",A2,SEARCH(" ",A2,1)+1)",A2,1))
",A2,1)+1))
SEARCH(" ",A2,1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name
The first name starts with the first character from the left (J) and ends at the fifth character (the first
space). The formula extracts the first 5 characters in A2, starting from the left.

## Use the SEARCH function to find the value for num_chars:

Search for the numeric position of the first space in A2, starting from the left. (5)
Middle name
The middle name starts at the sixth character position (Q), and ends at the eigth position (the second
space). This formula involves nesting SEARCH functions to find the second instance of a space.
The formula extracts 3 characters starting from the sixth position.

## Use the SEARCH function to find the value for start_num:

Search for the numeric position of the first space in A2 starting from the first character from the

left. (5)
Add 1 to get the character after the first space (Q). This numeric position is the starting position of
the middle name. (5 + 1 = 6)
Use nested SEARCH functions to find the value for num_chars:
Search for the numeric position of the first space in A2 starting from the first character from the
left. (5)
Add 1 to get the character after the first space (Q). The result is the character number at which you
want to start searching for the second instance of space. (5 + 1 = 6)
Search for the second instance of space in A2 starting from the 6th position (Q) found in Step 4.
This character number is the ending position of the middle name. (8)
Search for the numeric position of space in A2 starting from the first character from the left. (5)
Take the character number of the second space found in Step 5 and subtract the character number
of the first space found in Step 6. The result is the number of characters MID will extract from the
text string starting at the 6th position found in Step 2. (8 5 = 3)
Last name
The last name starts 6 characters from the right (at P) and ends at the first character from the right
(c). This formula involves nesting SEARCH functions to find the second and third instances of a
space (which are at the fifth and eighth positions from the left).
The formula extracts 6 characters in A2, starting from the right.

Use the LEN and nested SEARCH functions to find the value for num_chars:
Search for the numeric position of space in A2 starting from the first character from the left. (5)
Add 1 to get the character after the first space (Q). The result is the character number at which you
want to start searching for the second instance of space. (5 + 1 = 6)
Search for the second instance of space in A2 starting from the 6th position (Q) found in Step 2.
This character number is the ending position of the middle name. (8)
Count the total length of the text string in A2, and then subtract the number of characters from the
left up to the second instance of space found in Step 3. The result is the number of characters to be
extracted from the right of the full name. (14 8 = 6)
Example 3: Janaina B. G. Bueno
In this example, there are two middle initials. The first and third instances of space separate the
name components.
A
B
C
D
1
First Name
Name
Middle Name (B. G.)
Last Name (Bueno)
(Janaina)
2
Janaina =LEFT(A2,
=MID(A2,SEARCH("
=RIGHT(A2,LEN(A2)B. G.
SEARCH("
",A2,1)+1,SEARCH("
SEARCH(" ",A2,SEARCH("

",A2,SEARCH(" ",A2,SEARCH("
",A2,SEARCH(" ",A2,1)+1)+1))
",A2,1)+1)+1)-SEARCH(" ",A2,1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name
The first name starts with the first character from the left (J) and ends at the eighth character (the
first space). The formula extracts the first 8 characters in A2, starting from the left.
Bueno

",A2,1))

## Use the SEARCH function to find the value for num_chars:

Search for the numeric position of the first space in A2, starting from the left. (8)
Middle name
The middle name starts at the ninth position (B), and ends at the fourteenth position (the third space).
This formula involves nesting SEARCH to find the first, second, and third instances of space in the
eighth, eleventh, and fourteenth positions.
The formula extracts 5 characters, starting from the ninth position.

## Use the SEARCH function to find the value for start_num:

Search for the numeric position of the first space in A2, starting from the first character from the
left. (8)
Add 1 to get the character after the first space (Q). This numeric position is the starting position of
the middle name. (8 + 1 = 9)
Use nested SEARCH functions to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the first character from the
left. (8)
Add 1 to get the character after the first space (Q). The result is the character number at which you
want to start searching for the second instance of space. (8 + 1 = 9)
Search for the second space in A2, starting from the ninth position (B) found in Step 4. (11)
Add 1 to get the character after the second space (G). This character number is the starting position
at which you want to start searching for the third space. (12)
Search for the third space in A2, starting at the twelfth position found in Step 6. (14)

Search for the numeric position of first space (Q) in A2. (8)
Take the character number of the third space found in Step 7 and subtract the character number of
the first space found in Step 6. The result is the number of characters MID will extract from the text
string starting at the ninth position found in Step 2.
Last name
The last name starts 5 characters from the right (B) and ends at the first character from the right (o).
This formula involves nesting SEARCH to find the first, second, and third instances of space in the
eighth, eleventh, and fourteenth positions.
The formula extracts 5 characters in A2, starting from the right of the full name.

Use nested SEARCH and the LEN functions to find the value for the num_chars:
Search for the numeric position of the first space in A2, starting from the first character from the
left. (8)
Add 1 to get the character after the first space (Q). The result is the character number at which you
want to start searching for the second instance of space. (8 + 1 = 9)
Search for the second space in A2, starting from the ninth position (B) found in Step 2. (11)
Add 1 to get the character after the second space (G). This character number is the starting position
at which you want to start searching for the third instance of space. (12)
Search for the third space in A2, starting at the twelfth position found in Step 6. (14)
Count the total length of the text string in A2, and then subtract the number of characters from the
left up to the third space found in Step 5. The result is the number of characters to be extracted from
the right of the full name. (19 - 14 = 5)
Back to the top
Example 4: Kahn, Wendy Beth
In this example, the last name comes before the first name, and the middle name appears at the end.
The comma marks the end of the last name, and a space separate each name component.
A
B
C
D
Last Name
Name
First Name (Wendy)
Middle Name (Beth)
(Kahn)
1
=MID(A2,SEARCH("
Kahn,
=RIGHT(A2,LEN(A2)=LEFT(A2,
2
",A2,1)+1,SEARCH("
Wendy
SEARCH(" ",A2,SEARCH(" SEARCH("
",A2,SEARCH(" ",A2,1)+1)Beth
",A2,1)+1))
",A2,1)-2)
SEARCH(" ",A2,1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name

The first name starts with the seventh character from the left (W) and ends at the 12th character (the
second space),. Since the first name occurs at the middle of the full name, you need to use the MID
function to extract the first name.
The formula extracts 6 characters, starting from the seventh position.

## Use the SEARCH function to find the value for start_num:

Search for the numeric position of the first space in A2, starting from the first character from the
left. (6)
Add 1 to get the character after the first space (W). This numeric position is the starting position of
the first name. (6 + 1 = 7)
Use nested SEARCH functions to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the first character from the
left. (6)
Add 1 to get the character after the first space (W). The result is the character number at which you
want to start searching for the second space. (6 + 1 = 7)
Search for the second space in A2, starting from the seventh position (W) found in Step 4. (12)
Search for the numeric position of the first space in A2, starting from the first character from the
left. (12)
Take the character number of the second space found in Step 5 and subtract the character number
of the first space found in Step 6. The result is the number of characters MID will extract from the
text string starting at the seventh position found in Step 2. (12 - 6 = 6)
Middle name
The middle name starts 4 characters from the right (B), and ends at the first character from the right
(h). This formula involves nesting SEARCH to find the first and second instances of space in the
sixth and twelfth positions from the left.
The formula extracts 4 characters, starting from the right.

Use nested SEARCH and the LEN functions to find the value for start_num:

Search for the numeric position of the first space in A2, starting from the first character from the
left. (6)
Add 1 to get the character after the first space (Q). The result is the character number at which you
want to start searching for the second space. (6 + 1 = 7)
Search for the second instance of space in A2 starting from the 9th position (B) found in Step 2.
(12)
Count the total length of the text string in A2, and then subtract the number of characters from the
left up to the second space found in Step 3. The result is the number of characters to be extracted
from the right of the full name. (16 - 12 = 4)
Last name
The last name starts with the first character from the left (K) and ends at the fourth character (4). The
formula extracts 4 characters, starting from the left.

## Use the SEARCH function to find the value for num_chars:

Search for the numeric position of the first space in A2, starting from the first character from the
left. (6)
Subtract 2 to get the numeric position of n, the ending character of the last name. The result is
the number of characters you want LEFT to extract. (6 - 2 =4)
Back
Example 5: Mary Kay D. Andersen
In this example, there are two parts of the first name: Mary Kay. The second and third spaces
separate each name component.
A
B
C
D
First Name (Mary
Name
Middle Name (D.)
Last Name (Andersen)
Kay)
=MID(A2,SEARCH("
=RIGHT(A2,LEN(A2)1
=LEFT(A2,
",A2,SEARCH("
Mary
SEARCH("
2
SEARCH("
",A2,1)+1)+1,SEARCH("
Kay A.
",A2,SEARCH("
",A2,SEARCH(" ",A2,SEARCH(" ",A2,SEARCH("
Wilde
",A2,SEARCH("
",A2,1)+1))
",A2,1)+1)+1)-(SEARCH("
",A2,1)+1)+1))
",A2,SEARCH(" ",A2,1)+1)+1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name
The first name starts with the first character from the left and ends at the ninth character (the second
space). This formula involves nesting SEARCH to find the second instance of space from the left.
The formula extracts 9 characters, starting from the left.

## Use nested SEARCH functions to find the value for num_chars:

Search for the numeric position of the first space in A2, starting from the first character from the
left. (5)
Add 1 to get the character after the first space (K). The result is the character number at which you
want to start searching for the second instance of space. (5 + 1 = 6)
Search for the second instance of space in A2, starting from the sixth position (K) found in Step 2.
The result is the number of characters LEFT extracts from the text string. (9)
Middle name
The middle name starts at the tenth position (D), and ends at the twelfth position (the third space).
This formula involves nesting SEARCH to find the first, second, and third instances of space in the
5th, 9thth , and 12th positions.
The formula extracts 2 characters from the 9th position.

## Use nested SEARCH functions to find the value for start_num:

Search for the numeric position of the first space in A2, starting from the first character from the
left. (5)
Add 1 to get the character after the first space (K). The result is the character number at which you
want to start searching for the second space. (5 + 1 = 6)
Search for the second instance of space in A2, starting from the 6th position (K) found in Step 2.
The result is the number of characters LEFT extracts from the left. (9)
Add 1 to get the character after the second space (D). The result is the starting position of the
middle name. (9 + 1 = 10)
Use nested SEARCH functions to find the vlaue for num_chars:
Search for the numeric position of D. The result is the character number at which you want to
start searching for the third space. (10)
Search for the numeric position of the third space in A2, starting from the left. The result is the

## ending position of the middle name. (12)

Search for the numeric position of D. The result is the beginning position of the middle name.
(10)
Take the character number of the third space found in Step 6 and subtract the character number of
D found in Step 7. The result is the number of characters MID will extract from the text string
starting at the 10th position found in Step 4. (12 - 10 = 2)
Last name
The last name starts 8 characters from the right. This formula involves nesting SEARCH to find the
first, second, and third instances of space in the fifth, ninth , and twelfth positions.
The formula extracts 8 characters from the right.

Use nested SEARCH and the LEN functions to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the left. (5)
Add 1 to get the character after the first space (K). The result is the character number at which you
want to start searching for the space. (5 + 1 = 6)
Search for the second space in A2, starting from the 6th position (B) found in Step 2. (9)
Add 1 to get the character after the second space (D). The result is the starting position of the
middle name. (9 + 1 = 10)
Search for the numeric position of the third space in A2, starting from the left. The result is the
ending position of the middle name. (12)
Count the total length of the text string in A2, and then subtract the number of characters from the
left up to the third space found in Step 5. The result is the number of characters to be extracted from
the right of the full name. (20 - 12 = 8)
Back to the top
Example 6: Paula Barreto de Mattos
In this example, there are three parts of the last name: Barreto de Mattos. The first space marks the
end of the first name and the beginning of the last name.
A
B
D
Name
First Name (Paula)
Last Name (Barreto de Mattos)
1
Paula Barreto de
=LEFT(A2, SEARCH("
=RIGHT(A2,LEN(A2)-SEARCH("
2
Mattos
",A2,1))
",A2,1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name
The first name starts with the first character from the left (P) and ends at the sixth character(the first
space). The formula extracts 6 characters from the left.

## Use the Search function to find the value for num_chars:

Search for the numeric position of the first space in A2, starting from the left. (6)
Last name
The last name starts 17 characters from the right (B) and ends with first character from the right (s).
The formula extracts 17 characters from the right.

Use the LEN and SEARCH functions to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the left. (6)
ount the total length of the text string in A2, and then subtract the number of characters from the
left up to the first space found in Step 1. The result is the number of characters to be extracted from
the right of the full name. (23 - 6 = 17)
Back to the top
Example 7: James van Eaton
In this example, there are two parts of the last name: van Eaton. The first space marks the end of the
first name and the beginning of the last name.
A
B
D
Name
First Name (James)
Last Name (van Eaton)
1
=LEFT(A2, SEARCH("
2 James van Eaton
=RIGHT(A2,LEN(A2)-SEARCH(" ",A2,1))
",A2,1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name
The first name starts with the first character from the left (J) and ends at the eigth character (the first
space). The formula extracts 6 characters from the left.

## Use the SEARCH function to find the value for num_chars:

Search for the numeric position of the first space in A2, starting from the left. (6)
Last name
The last name starts with the ninth character from the right (v) and ends at the first character from
the right (n). TThe formula extracts 9 characters from the right of the full name.

Use the LEN and SEARCH functions to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the left. (6)
Count the total length of the text string in A2, and then subtract the number of characters from the
left up to the first space found in Step 1. The result is the number of characters to be extracted from
the right of the full name. (15 - 6 = 9)
Back to the top
Example 8: Bacon Jr., Dan K.
In this example, the last name comes first followed by the suffix. The comma separates the last name
and suffix from the first name and middle initial.
A
B
C
D
E
Last Name
Name First Name (Dan)
Middle Name (K.)
Suffix (Jr.)
(Bacon)
=MID(A2,SEARCH("
",A2,SEARCH("
=MID(A2,SEARCH("
1 Bacon ",A2,1)+1)+1,SEARCH(" =RIGHT(A2,LEN(A2)", A2,1)+1,
",A2,SEARCH("
SEARCH("
=LEFT(A2,
2 Jr.,
(SEARCH("
",A2,SEARCH("
",A2,SEARCH("
SEARCH("
Dan
",A2,SEARCH("
",A2,1)+1)+1)",A2,SEARCH("
",A2,1))
K.
",A2,1)+1)-2)SEARCH("
",A2,1)+1)+1))
SEARCH(" ",A2,1))
",A2,SEARCH("
",A2,1)+1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name
The first name starts with the twelfth character (D) and ends with the fifteenth character (the third
space). The formula extracts 3 characters starting from the twelfth position.

## Use nested SEARCH functions to find the value for start_num:

Search for the numeric position of the first space in A2, starting from the left. (6)
Add 1 to get the character after the first space (J). The result is the character number at which you
want to start searching for the second space. (6 + 1 = 7)
Search for the second space in A2, starting from the 7th position (J) found in Step 2. (11)
Add 1 to get the character after the second space (D). The result is the starting position of the first
name. (11 + 1 = 12)
Use nested SEARCH functions to find the value for num_chars:
Search for the numeric position of D. The result is the character number at which you want to
start searching for the third space. (12)
Search for the numeric position of the third space in A2 ,starting from the left. The result is the
ending position of the first name. (15)
Search for the numeric position of D. The result is the beginning position of the first name. (12)
Take the character number of the third space found in Step 6 and subtract the character number of
D found in Step 7. The result is the number of characters MID will extract from the text string
starting at the 12th position found in Step 4. (15 - 12 = 3)
Middle name
The middle name starts with the second character from the right (K). The formula extracts 2
characters from the right.

## Use nested SEARCH functions to find the value for num_chars:

Search for the numeric position of the first space in A2, starting from the left. (6)
Add 1 to get the character after the first space (J). The result is the character number at which you
want to start searching for the second space. (6 + 1 = 7)

Search for the second space in A2, starting from the 7th position (J) found in Step 2. (11)
Add 1 to get the character after the second space (D). The result is the starting position of the first
name. (11 + 1 = 12)
Search for the numeric position of the third space in A2 starting from the left. The result is the
ending position of the middle name. (15)
Count the total length of the text string in A2, and then subtract the number of characters from the
left up to the third space found in Step 5. The result is the number of characters to be extracted from
the right of the full name. (17 - 15 = 2)
Last name
The last name starts at the first character from the left (B) and ends at sixth character (the first
ispace). Therefore, the formula extracts 6 characters from the left.

## Use the SEARCH function to find the value for num_chars:

Search for the numeric position of the first space in A2, starting from the left. (6)
Suffix
The suffix starts at the seventh character from the left (J), and ends at ninth character from the left
(.). The formula extracts 3 characters starting from the seventh character.

## Use the SEARCH function to find the value for start_num:

Search for the numeric position of the first space in A2, starting from the left. (6)
Add 1 to get the character after the first space (J). The result is the starting position of the suffix. (6
+ 1 = 7)
Use nested SEARCH functions to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the left. (6)
Add 1 to get the numeric position of J. The result is the character number at which you want to
start searching for the second space. (7)
Search for the numeric position of the second space in A2 starting from the 7th character found in
Step 4. (11)
Subtract 1 from the character number of the second space found in Step 4 to get the character
number of ,. The result is the ending position of the suffix. (11 - 1 = 10)
and Search for the numeric position of J also found in Steps 3 and 4. (7)

Take the character number of , found in Step 6 and subtract the character number of J found in
Steps 3 and 4. The result is the number of characters MID will extract from the text string starting at
the 7th position found in Step 2. (10 - 7 = 3)
Example 9: Gary Altman III
In this example, the first name is at the beginning of the string and the suffix is at the end of the
name format. The formula to use for the name components is similar to Example 2, where the first
name can be extracted using the LEFT function, the last name using the MID function, and the suffix
using the RIGHT function.
A
B
C
D
First Name
Name
Last Name (Altman)
Suffix (III)
(Gary)
1
=MID(A2,SEARCH("
Gary
=LEFT(A2,
=RIGHT(A2,LEN(A2)2
",A2,1)+1,SEARCH("
Altman SEARCH("
SEARCH(" ",A2,SEARCH("
",A2,SEARCH(" ",A2,1)+1)III
",A2,1))
",A2,1)+1))
(SEARCH(" ",A2,1)+1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name
The first name starts at the first character from the left (G) and ends at the fifth character (the first
space). Therefore, the formula extracts 5 characters from the left of the full name.

Search for the numeric position of the first space in A2 starting from the left. (5)
Last name
The last name starts at the sixth character from the left (A) and ends at the eleventh character (the
second space). This formula involves nesting SEARCH to find the positions of the spaces.
The formula extracts 6 characters starting from the 6th character.

## Use the SEARCH function to find the value for start_num:

Search for the numeric position of the first space in A2, starting from the left. (5)
Add 1 to get the character after the first space (A). The result is the starting position of the suffix.
(5 + 1 = 6)
Use nested SEARCH functions to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the left. (5)
Add 1 to get hte character after the first space (A). The result is the character number at which you
want to start searching for the second space. (5 + 1 = 6)
Search for the numeric position of the second space in A2, starting from the 6th character found in
Step 4. This character number is the ending position of the last name. (12)
and Search for the numeric position of A also found in Steps 3 and 4. (6)
Take the character number of the second space found in Step 5, and then subtract the character
number of A found in Steps 6 and 7. The result is the number of characters MID will extract from
the text string, starting at the 6th position found in Step 2. (12 - 6 = 6)
Suffix
The suffix starts 3 characters from the right. This formula involves nesting SEARCH to find the
positions of the spaces.

Use nested SEARCH and the LEN functions to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the left. (5)
Add 1 to get the character after the first space (A). The result is the character number at which you
want to start searching for the second space. (5 + 1 = 6)
Search for the second space in A2, starting from the 6th position (A) found in Step 2. (12)
Count the total length of the text string in A2, and then subtract the number of characters from the
left up to the second space found in Step 3. The result is the number of characters to be extracted
from the right of the full name. (15 - 12 = 3)
Example 10: Mr. Ryan Ihrig
In this example, the full name is preceded by a prefix. The formulas to use for the name components
is similar to Example 2, where the first name can be extracted using the MID function and the last
name using the RIGHT function.
A
B
C
Name
First Name (Ryan)
Last Name (Ihrig)
1
=MID(A2,SEARCH(" ",A2,1)+1,SEARCH("
Mr. Ryan
=RIGHT(A2,LEN(A2)-SEARCH("
2
",A2,SEARCH(" ",A2,1)+1)-(SEARCH("
Ihrig
",A2,SEARCH(" ",A2,1)+1))
",A2,1)+1))
Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.

First name
The first name starts at the fifth character from the left (R) and ends at the ninth character (the
second space). This formula involves nesting SEARCH to find the positions of the spaces.
The formula extracts 4 characters from the 5th position.

Use the SEARCH function to find the value for the start_num:
Search for the numeric position of the first space in A2, starting from the left. (4)
Add 1 to get the character after the first space (R). The result is the starting position of the suffix.
(4 + 1 = 5)
Use nested SEARCH function to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the left. (4)
Add 1 to get the character after the first space (R). The result is the character number at which you
want to start searching for the second space. (4 + 1 = 5)
Search for the numeric position of the second space in A2 starting from the 5th character found in
Steps 3 and 4. This character number is the ending position of the first name. (9)
and Search for the numeric position of R also found in Steps 3 and 4. (5)
Take the character number of the second space found in Step 5, and then subtract the character
number of R found in Steps 6 and 7. The result is the number of characters MID will extract from
the text string, starting at the 5th position found in Step 2. (9 - 5 = 4)
Last name
The last name starts 5 characters from the right. This formula involves nesting SEARCH to find the
positions of the spaces.

Use nested SEARCH and the LEN functions to find the value for num_chars:
Search for the numeric position of the first space in A2, starting from the left. (4)
Add 1 to get the character after the first space (R). The result is the character number at which you
want to start searching for the second space. (4 + 1 = 5)
Search for the second space in A2 starting from the 5th position (R) found in Step 2. (9)

Count the total length of the text string in A2, and then subtract the number of characters from the
left up to the second ispace found in Step 3. The result is the number of characters to be extracted
from the right of the full name. (14 - 9 = 5)
Example 11: Julie Taft-Rider
In this example, the last name is hyphenated. A space separates each name component.
A
B
C
Name
First Name (Julie)
Last Name (Taft-Rider)
Julie Taft-Rider =LEFT(A2, SEARCH(" ",A2,1)) =RIGHT(A2,LEN(A2)-SEARCH(" ",A2,1))
1
2

Note In the following pictures, the highlight in the full name shows the character that the matching
SEARCH formula is looking for.
First name
The first name starts at the first character from the left and ends at the sixth position (the first space).
The formula extracts 6 characters from the left.

## Use the SEARCH function to find the value of num_chars:

Search for the numeric position of the first space in A2, starting from the left. (6)
Last name
The entire last name starts 10 characters from the right (T) and ends at the first character from the
right (r).

Use the LEN and SEARCH functions to find the value for num_chars:
Search for the numeric position of space in A2, starting from the first character from the left. (6)
Count the total length of the text string to be extracted, and then subtract the number of characters
from the left up to the first space found in Step 1. (16 - 6 = 10)

## Create conditional formulas

Help

Show All
Testing whether conditions are true or false and making logical comparisons between
expressions are common to many tasks. You can use the AND, OR, NOT, and IF
function to create conditional formulas.
The IF function uses the following arguments.
Formula with the IF function
logical_test: The condition that you want to check.
value_if_true: The value to return if the condition is true.
value_if_false: The value to return if the condition is false.
What do you want to do?
Create a conditional formula that results in a logical value (TRUE or FALSE)
Create a conditional formula that results in another calculation or in values other than
TRUE or FALSE
Create a conditional formula that results in a logical value (TRUE or FALSE)
To do this task, use the AND, OR, and NOT functions, and 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.).
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
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.
To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.
A
1 Data
2 15
3 9
4 8
Sprockets
Widgets

Formula
=AND(A2>A3, A2<A4)
=OR(A2>A3, A2<A4)
=NOT(A2+A3=24)
=NOT(A5="Sprockets")
=OR(A5<>"Sprockets",A6 =
"Widgets")
Function details
AND
OR
NOT
Top of Page

Description (Result)
Is 15 greater than 9 and less than 8? (FALSE)
Is 15 greater than 9 or less than 8? (TRUE)
Is 15 plus 9 not equal to 24? (FALSE)
Is A5 not equal to "Sprockets"? (FALSE)
Is A5 not equal to "Sprockets" or A6 equal to
"Widgets"? (TRUE)

Create a conditional formula that results in another calculation or in values other than
TRUE or FALSE
To do this task, use the IF, AND, and OR functions.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
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.
To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.
A
1 Data
2 15
3 9
4 8
Sprockets
Widgets
Formula
Description (Result)
If the value in cell A2 equals 15, then
=IF(A2=15, "OK", "Not OK")
return "OK". (OK)
=IF(A2<>15, "OK", "Not OK")
If the value in cell A2 is not equal to 15,

## then return "OK". (Not OK)

If the value in cell A2 is not less than or
=IF(NOT(A2<=15), "OK", "Not OK")
equal to 15, then return "OK". (Not OK)
If the value in cell A5 is not equal to
=IF(A5<>"SPROCKETS", "OK", "Not
"SPROCKETS", then return "OK". (Not
OK")
OK)
=IF(AND(A2>A3, A2<A4), "OK",
If 15 is greater than 9 and less than 8, then
"Not OK")
return "OK". (Not OK)
=IF(AND(A2<>A3, A2<>A4), "OK", If 15 is not equal to 9 and 15 is not equal
"Not OK")
to 8, then return "OK". (OK)
=IF(OR(A2>A3, A2<A4), "OK", "Not If 15 is greater than 9 or less than 8, then
OK")
return "OK". (OK)
If the value in cell A5 is not equal to
=IF(OR(A5<>"Sprockets",
"Sprockets" or "Widgets", then return
A6<>"Widgets"), "OK", "Not OK")
"OK". (Not OK)
=IF(OR(A2<>A3, A2<>A4), "OK",
If 15 is not equal to 9 or 15 is not equal to
"Not OK")
8, then return "OK". (OK)
Function details
IF
AND
OR