Beruflich Dokumente
Kultur Dokumente
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.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
15
9
8
Sprockets
Widgets
Formula
Description (Result)
=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
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
15
3
9
4
8
Sprockets
Widgets
Formula
Description (Result)
=IF(OR(A5<>"Sprockets", A6<>"Widgets"),
"OK", "Not OK")
Function details
IF
AND
OR
o
o
To display zero (0) values in cells, select the Zero values check box.
NOTES
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.
Select the example in the Help topic.
2. Press CTRL+C. In the worksheet, select cell A1, and press CTRL+V.
3. To switch between viewing the results and viewing the formulas that return the results, press
CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show
Formulas button.
A
1
2
Data
10
3
10
Formula
Description (Result)
=A2-A3
=IF(A2-A3=0,"",A2-A3)
=IF(A2-A3=0,"-",A2-A3)
Function details
IF
TOP OF PAGE
Change error display Select the For error values, show check box under Format
options. In the box, type the value that you want to display instead of errors. To display
errors as blank cells, delete any characters in the box.
Change empty cell display Select the For empty cells, show check box. In the box,
type the value that you want to display in empty cells. To display blank cells, delete any
characters in the box. To display zeros, clear the check box.
Let's say your spreadsheet formulas have errors that you anticipate and don't need to
correct, but you want to improve the display of your results. There are several ways to
hide error values and error indicators in cells.
There are many reasons why formulas can return errors. For example, division by 0 is not
allowed, and if you enter the formula =1/0, it returns #DIV/0. Error values include
#DIV/0!, #N/A, #NAME?, #NULL!, #NUM!, #REF!, and #VALUE!.
Format text in cells that contain errors so that they don't show
1. Select the cells that contain the error value.
2. On the Format menu, click Conditional Formatting.
3. In the box on the left, click Formula Is.
4. In the box on the right, type =ISERROR(reference), where reference is a reference to the cell that
contains the error value.
5. Click Format, and then click the Font tab.
6. Click Format.
7. In the Color box, select white.
TOP OF PAGE
=IF(ISERROR(old_formula),"",old_formula)
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
10
0
Formula
Description (Result)
=A2/A3
=IF(ISERROR(A2/A3),"NA",A2/A3)
=IF(ISERROR(A2/A3),"-",A2/A3)
=IF(ISERROR(A2/A3),NA(),A2-A3)
Function details
IF
ISERROR
NA
TOP OF PAGE
Change error display Select the For error values, show check box under Format
options. In the box, type the value that you want to display instead of errors. To display
errors as blank cells, delete any characters in the box.
Change empty cell display Select the For empty cells, show check box. In the box,
type the value that you want to display in empty cells. To display blank cells, delete any
characters in the box. To display zeros, clear the check box.
TOP OF PAGE
1. On the Tools menu, click Options and then click the Error Checking tab.
2. Clear the Enable background error checking check box.
Let's say you want to look up an employee's phone extension by using their badge
number, or the correct rate of a commission for a sales amount. You look up data to
quickly and efficiently find specific data in a list and to automatically verify that you are
using correct data. After you look up the data, you can perform calculations or display
results with the values returned. There are several ways to look up values in a list of data
and to display the results.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
Badge Number
Last Name
First
Name
Exten
ID-34567
Davolio
Nancy
5467
ID-16782
Fuller
Andrew
3457
ID-4537
Leverling
Janet
3355
ID-1873
Peacock
Margaret
5176
ID-3456
Buchanan
Steven
3453
ID-5678
Suyama
Michael
428
Formula
Description (Result)
=VLOOKUP("ID-4537",
A1:D7, 4, FALSE)
2
3
4
Function details
VLOOKUP
TOP OF PAGE
Example
1
2
Frequency
Color
4.14
red
4.19
orange
5.17
yellow
5.77
green
6.39
blue
Formula
Description (Result)
=VLOOKUP(5.93, A1:B6,
2, TRUE)
3
4
5
6
Function details
VLOOKUP
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Status
Axles
Bolts
In stock
On order
10
Back order
11
Formula
Description (Result)
=HLOOKUP("Bolts", A1:C4,
3)
3
4
Function details
HLOOKUP
TOP OF PAGE
Example
10000
50000
100000
Sales
Volume
.05
.20
.30
Rate
Formula
Description (Result)
=HLOOKUP(78658,A1:D4,2,
TRUE)
Looks up $78,658 in
Row 1, finds the next
largest value that is
less than $78,658,
which is $50,000, and
then returns the
value from row 2
that's in the same
column as $50,000
(20%)
3
4
NOTES
To display the rate and return number as a percentage, select the cell and then click Percent
Style
on theFormatting toolbar.
To display the Sales Volume number as dollars, select the cell and then click Dollar Style
theFormatting toolbar.
Function details
HLOOKUP
TOP OF PAGE
on
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Product
Count
Bananas
38
Oranges
25
Apples
41
Pears
40
3
4
5
Formula
Description (Result)
=INDEX(A2:B5,MATCH("Pears",A2:A5,0),2)
Looks up Pears in column A and returns the value for Pears in colum
(40).
Function details
INDEX
MATCH
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Product
Count
Bananas
38
Oranges
25
Apples
41
Pears
40
Formula
Description (Result)
=OFFSET(A1,MATCH("Pears",A2:A5,
0),1)
Looks up Pears in column A and returns the value for Pears in column
40).
3
4
5
A1: The upper left cell of the range, also called the starting cell.
MATCH("Pears",A2:A5, 0): The MATCH function determines the row number below the
starting cell to find the look up value.
Add dates
Show All
Let's say you want to adjust a revised schedule date by adding two weeks to see what
the new completion date will be, or you need to determine how long an activity will take
to complete in a list of project tasks. There are several ways to add dates.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Date
Days to add
6/9/2007
=TODAY()
12/10/2008
54
Formula
Description (Result)
=A2+B2
=A3+B3
=A4+B4
3
4
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
3
Date
Months to add
6/9/2007
9/2/2007
12/10/2008
25
Formula
Description (Result)
=DATE(YEAR(A2),MONTH(A2)+B2,DAY(A2))
=DATE(YEAR(A3),MONTH(A3)+B3,DAY(A3))
=DATE(YEAR(A4),MONTH(A4)+B4,DAY(A4))
Function details
DATE
YEAR
MONTH
DAY
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
Date
Years to add
2
3
6/9/2007
9/2/2007
12/10/2008
25
Formula
Description (Result)
=DATE(YEAR(A2)+B2,MONTH(A2),DAY(A2))
=DATE(YEAR(A3)+B3,MONTH(A3),DAY(A3))
=DATE(YEAR(A4)+B4,MONTH(A4),DAY(A4))
Function details
DATE
YEAR
MONTH
DAY
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
Date
6/9/2007
Formula
Description (Result)
=DATE(YEAR(A2)+3,MONTH(A2)+1,DAY(A2)+5)
=DATE(YEAR(A2)+1,MONTH(A2)+7,DAY(A2)+5)
Function details
DATE
YEAR
MONTH
DAY
Add times
Show All
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to sum the total time a set of tasks will take so that you can calculate
a contract rate, or you want to sum the number of minutes in different legs of a race to
get the total time. There are several ways to add times.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Hours worked
1:35
3
8:30
4
5
3:00
4:15
8:00
Formula
Description (Result)
=SUM(A2:A5)
Total hours worked when the total is less than a day (17:20)
=SUM(A2:A6)*24
Total hours worked when the total is greater than a day (25.33333).
Notes
To view the second formula as a number, select the cell and click Cells on the Format menu. Click
the Numbertab, and then click General in the Category box.
If the time you are adding contain seconds, format the cell with time format that displays seconds.
Select the cell and click Cells on the Format menu. Click the Number tab, and then click Time in
the Category box.
Function details
SUM
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Time
Description
Amount
10:35:00 AM
Hours
10:35:00 AM
Minutes
10
10:35:00 AM
Seconds
30
Formula
Description (Result)
=A2+TIME(C2,0,0)
=A3+TIME(0,C3,0)
=A4+TIME(0,0,C4)
3
4
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want find out how many days a customer takes to pay a bill or how long it
takes to ship a product upon receipt of an approved order. There are several ways to
calculate the difference between two dates.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
Date
6/8/2007
3
6/20/2007
Formula
Description
=A3-A2
=NETWORKDAYS(A2,A3)
To view the dates as numbers, select the cell and click Cells on
the Format menu. Click the Numbertab, and then click Number in the Category box.
NOTE
Function details
NETWORKDAYS
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
Date
6/9/2007
3
9/2/2007
4
12/10/2008
Formula
Description (Result)
=MONTH(A3)-MONTH(A2)
=(YEAR(A4)-YEAR(A3))*12+MONTH(A4)-MONTH(A3)
To view the dates as numbers, select the cell and click Cells on
the Format menu. Click the Numbertab, and then click Number in the Category box.
NOTE
Function details
MONTH
YEAR
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Date
6/9/2007
3
6/4/2010
Formula
Description (Result)
=YEAR(A3)-YEAR(A2)
NOTES
To view the dates as numbers, select the cell and click Cells on the Format menu. Click
the Number tab, and then click Number in the Category box.
You cannot subtract a date that is later than another date, or the error #### appears in the cell.
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want find out how long it takes for an employee to complete an assembly
line operation or a fast food order to be processed at peak hours. There are several ways
to calculate the difference between two times.
When you use the time format codes, hours never exceed 24, minutes never exceed 60,
and seconds never exceed 60.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Start time
End time
6/9/2007 10:35 AM
6/9/2007 3:30 PM
Formula
Description (Result)
=B2-A2
Hours between two times with the cell formatted as "h" (4)
=B2-A2
Hours and minutes between two times with the cell formatted as "h:mm" (4:55)
=B2-A2
Hours, minutes, and seconds between two times with the cell formatted as "h:mm:ss"
(4:55:00)
=TEXT(B2-A2,"h")
=TEXT(B2-A2,"h:mm")
=TEXT(B2A2,"h:mm:ss")
The previous example shows two ways to calculate the difference between two times.
You can use:
A simple subtraction formula, and then format the result by selecting the Custom category and
entering the appropriate format code in the Type box under the Number tab of the Format
Cells dialog box.
The TEXT function which has a formatting argument.
If you use both a format applied with the TEXT function and number format, the
TEXT function takes precedence.
NOTE
To do this task, use the INT function, or HOUR, MINUTE, and SECOND functions.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Start time
End time
6/9/2007 10:35 AM
6/10/2007 3:30 PM
Formula
Description (Result)
=INT((B2-A2)*24)
=(B2-A2)*1440
=(B2-A2)*86400
=HOUR(B2-A2)
Hours between two times, when the difference does not exceed 24. (4)
=MINUTE(B2-A2)
Minutes between two times, when the difference does not exceed 60. (55)
=SECOND(B2-A2)
Seconds between two times, when the difference does not exceed 60. (0)
Let's say you want to find out how many days there are between two project dates or
find out how many shopping days there are before a holiday. To count the days before a
date, you can use the TODAY function.
Example
The example may be easier to understand if you copy it to a blank worksheet.
Date
1/1/2008
3
6/1/2007
Formula
Description (Result)
=A2-TODAY()
=A2-A3
Notes
In the first formula above, the current date used is taken from the system clock.
In the last formula above, to view the date as a number, select the cell and click Cells on
the Format menu. Click the Number tab, and then click Number in the Category box.
Let's say you want to find out how many days there are between two project dates or
find out how many shopping days there are before a holiday. To count the days before a
date, you can use the TODAY function.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Date
1/1/2008
3
6/1/2007
Formula
Description (Result)
=A2-TODAY()
=A2-A3
Notes
In the first formula above, the current date used is taken from the system clock.
In the last formula above, to view the date as a number, select the cell and click Cells on
the Format menu. Click the Number tab, and then click Number in the Category box.
Let's say you want to see the date displayed for a date value in a cell as "Monday"
instead of the actual date of "October 3, 2005." There are several ways to show dates as
days of the week.
3. Under Category, click Custom, and in the Type box, type dddd for the full name of the day of the
week (Monday, Tuesday, and so on), or ddd for the abbreviated name of the day of the week (Mon,
Tue, Wed, and so on).
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Date
19-Feb-2007
3
3-Jan-2008
Formula
Description (Result)
=TEXT(A2,
"dddd")
Calculates the day of the week for the date and returns the full name of the day of the week
(Monday)
=TEXT(A3, "ddd")
Calculates the day of the week for the date and returns the abbreviated name of the day of t
week (Thu)
Function details
TEXT
Show All
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to easily enter the current date and time while making a time log of
activities or display the current date and time automatically in a cell every time formulas
are recalculated. There are several ways to insert the current date and time in a cell.
Current time
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=TODAY()
=NOW()
NOTE The TODAY() and NOW() functions change only when the worksheet is
calculated or when a macro that contains the function is run. They are not updated
continuously. The date and time used are taken from the computer's system clock.
A Julian date is sometimes used to refer to a date format that is a combination of the
current year and the number of days since the beginning of the year. For example,
January 1, 2007 is represented as 2007001 and December 31, 2007 is represented as
2007365. Note that this format is not based on the Julian calendar.
There is also a Julian date commonly used in astronomy, which is a serial date system
starting on January 1, 4713 B.C.E.
There are several ways to insert Julian dates.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
NOTES
The current date used is taken from the computer's system clock.
In the formulas above, the year begins on January 1 (1/1). To convert the formulas to use a different
starting date, edit the portion "1/1/" to the date that you want.
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to find the average number of days to complete a milestone in a
project or the average temperature on a particular day over a 10-year time span. There
are several ways to calculate the average of a group of numbers.
The AVERAGE function measures central tendency, which is the location of the center of
a group of numbers in a statistical distribution. The three most common measures of
central tendency are:
Average which is the arithmetic mean, and is calculated by adding a group of numbers and then
dividing by the count of those numbers. For example, the average of 2, 3, 3, 5, 7, and 10 is 30 divided
by 6, which is 5.
Median which is the middle number of a group of numbers; that is, half the numbers have values
that are greater than the median, and half the numbers have values that are less than the median.
For example, the median of 2, 3, 3, 5, 7, and 10 is 4.
Mode which is the most frequently occurring number in a group of numbers. For example, the
mode of 2, 3, 3, 5, 7, and 10 is 3.
ENTER.
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
Data
10
3
7
4
9
5
6
27
0
4
Formula
Description (Result)
=AVERAGE(A2:A7)
=AVERAGE(A2:A4,A7)
Averages the top three and the last number in the list (7.5)
=AVERAGE(IF(A2:A7<>0,
A2:A7,""))
Averages the numbers in the list except those that contain zero, such as cell
(11.4)
The last formula in the example must be entered as an array formula. After
copying the example to a blank worksheet, select the cell A11. Press F2, and then press
CTRL+SHIFT+ENTER. If the formula is not entered as an array formula, the error #VALUE!
is returned.
NOTE
Function details
AVERAGE
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
This example calculates the average price paid for a unit across three purchases, where
each purchase is for a different number of units at a different price per unit.
1
2
Number of units
20
500
25
750
35
200
Formula
Description (Result)
=SUMPRODUCT(A2:A4,B2:B4)/SUM(B2:B4)
Divides the total cost of all three orders by the total number of unit
ordered (24.66)
3
4
Function details
SUM
SUMPRODUCT
TOP OF PAGE
Example
Data
10
3
7
4
5
27
0
4
Formula
Description (Result)
=AVERAGE(IF(A2:A7<>0,
A2:A7,""))
Averages the numbers in the list except those that contain zero, such as cell
(11.4)
The formula in the example must be entered as an array formula. After copying
the example to a blank worksheet, select the cell A9. Press F2, and then press
CTRL+SHIFT+ENTER. If the formula is not entered as an array formula, the error #VALUE!
is returned.
NOTE
Let's say you want to find out what the midpoint is in a distribution of student grades or
a quality control data sample. To calculate the median of a group of numbers, use the
MEDIAN function.
The MEDIAN function measures central tendency, which is the location of the center of a
group of numbers in a statistical distribution. The three most common measures of
central tendency are:
Average which is the arithmetic mean, and is calculated by adding a group of numbers and then
dividing by the count of those numbers. For example, the average of 2, 3, 3, 5, 7, and 10 is 30 divided
by 6, which is 5.
Median which is the middle number of a group of numbers; that is, half the numbers have values
that are greater than the median, and half the numbers have values that are less than the median.
For example, the median of 2, 3, 3, 5, 7, and 10 is 4.
Mode which is the most frequently occurring number in a group of numbers. For example, the
mode of 2, 3, 3, 5, 7, and 10 is 3.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
10
3
7
4
5
27
0
4
Formula
Description (Result)
=MEDIAN(A2:A7)
Example
The example may be easier to understand if you copy it to a
blank worksheet.
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
2
Data
10
3
7
4
5
4
Formula
Description (Result)
=MODE(A2:A7)
Add numbers
Show All
Let's say you want to sum prices for all items not on sale in a store or sum gross profit
margins for all departments under budget. There are several ways to add numbers.
1. Click a cell below the column of numbers or to the right of the row of numbers.
2. Click AutoSum
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Salesperson
Invoice
Buchanan
15,000
Buchanan
9,000
4
5
Suyama
8,000
Suyama
20,000
Buchanan
5,000
Dodsworth
22,500
Formula
Description (Result)
=SUM(B2:B3, B5)
Adds two invoices from Buchanan, and one from Suyama (44,000)
=SUM(B2,B5,B7)
6
7
NOTE
Function details
SUM
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
Salesperson
Invoice
2
3
Buchanan
15,000
Buchanan
9,000
Suyama
8,000
Suyama
20,000
Buchanan
5,000
Dodsworth
22,500
Formula
Description (Result)
=SUMIF(A2:A7,"Buchanan",B2:B7)
=SUMIF(B2:B7,">=9000",B2:B7)
=SUMIF(B2:B7,"<9000",B2:B7)
4
5
6
7
Range to evaluate: Check these cells to determine whether a row meets your criteria.
Criteria: The condition that the cells you evaluate must meet for the row to be
included in the sum.
Range to sum: Add the numbers in these cells provided that the row satisfies the
condition.
Function details
SUMIF
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
Region
Salesperson
Type
South
Buchanan
Beverages
West
Davolio
Dairy
East
Suyama
Beverages
North
Suyama
Dairy
South
Dodsworth
Produce
South
Davolio
Meat
South
Davolio
Meat
East
Suyama
Produce
North
Davolio
Produce
South
Dodsworth
Meat
Formula
Description (Result)
1
2
3
4
5
8
9
10
11
=SUM(IF((A2:A11="South")*(C2:C11="Meat"),D2:D11))
=SUM(IF((A2:A11="South")+(A2:A11="East"),D2:D11))
The formulas in the example must be entered as array formulas. After copying
the example to a blank worksheet, select the formula cell. Press F2, and then press
CTRL+SHIFT+ENTER. If the formula is not entered as an array formula, the error #VALUE!
is returned.
NOTE
Function details
SUM
IF
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
3
Region
Salesperson
Type
South
Buchanan
Beverages
4
5
West
Davolio
Dairy
East
Suyama
Beverages
North
Suyama
Dairy
South
Dodsworth
Produce
South
Davolio
Meat
South
Davolio
Meat
East
Suyama
Produce
North
Davolio
Produce
South
Dodsworth
Meat
Region
Salesperson
Type
6
7
8
9
10
11
South
Meat
Produce
Formula
Description (Result)
=DSUM(A1:D11, "Sales",
A12:D13)
=DSUM(A1:D11, "Sales",
A12:D14)
Function details
DSUM
TOP OF PAGE
If the Conditional Sum command is not on the Wizard submenu on the Tools menu,
load the Conditional Sum Wizard add-in program.
How?
3. Follow the instructions in the wizard.
The formulas created by the Conditional Sum Wizard are array formulas. After
you edit these formulas, you must press CTRL+SHIFT+ENTER to lock in the formulas.
NOTE
TOP OF PAGE
FREQUENCY function to identify the unique values. For the first occurrence of a specific value, this
function returns a number equal to the number of occurrences of that value. For each occurrence of
that same value after the first, this function returns a 0 (zero).
IF function to assign a value of 1 to each true condition.
The SUM function to add the unique values.
Tip To see a function evaluated step by step, select the cell containing the formula.
Then, on the Tools menu, point to Formula Auditing and click Evaluate Formula.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
986
3
456
4
5
67
34
8
689
9
10
456
56
67
Formula
Description (Result)
=SUM(IF(FREQUENCY(A2:A10,A2:A10)>0,A2:A10))
NOTE The formulas in this example must be entered as array formulas. Select each cell
Example
The example may be easier to understand if you copy it to a
blank worksheet.
How to copy an example
A
1
2
Data
15,000
3
9,000
4
-8,000
Formula
Description (Result)
=A2-A3
=SUM(A2:A4)
Multiply numbers
Show All
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to figure out how much bottled water that you need for a customer
conference (total attendees 4 days 3 bottles per day) or the reimbursement travel
cost for a business trip (total miles .46). There are several ways to multiply numbers.
Example
The example may be easier to understand if you copy it to a blank worksheet.
Data
5
3
15
4
30
Formula
Description (Result)
=A2*A3
=PRODUCT(A2:A4)
=PRODUCT(A2:A4,2)
Divide numbers
Show All
Let's say you want to find out how many person hours it took to finish a project (total
project hours total people on project) or the actual miles per gallon rate for your
recent cross-country trip (total miles total gallons). There are several ways divide
numbers.
TOP OF PAGE
Data
15,000
3
12
Formula
Description (Result)
=A2/A3
Calculate percentages
Show All
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to calculate a sales tax for different states, compute a grade for a test
score, or determine a percent change in sales between two fiscal quarters. There are
several ways to calculate percentages.
Percentages are calculated by using the following equation:
amount/total = percentage
on
Example
The example may be easier to understand if you copy it to a blank worksheet.
1
2
Purchase price
800
0.089
Formula
Description (Result)
=A2*B2
Multiplies 800 by 0.089 to find the amount of sales tax to pay ($71.20)
example, the sales tax in this example (8.9) divided by 100 is .089.
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
42
50
Formula
Description (Result)
=A2/B2
NOTE To display the number as a percentage, select the cell and then click Percent
Style
on theFormatting toolbar.
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Sale price
15
0.75
Formula
Description (Result)
=A2/B2
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
November
earnings
December earnings
2342
2500
Formula
Description (Result)
=(B2A2)/ABS(A2)
Divides the difference between the second and first numbers by the absolute value of the firs
number to get the percentage change (0.06746 or 6.75%)
NOTE To display the number as a percentage, select the cell and then click Percent
Style
on theFormatting toolbar.
Function details
ABS
TOP OF PAGE
For example, you spend an average of $25 on food each week, and you want to cut your
weekly food expenditures by 25%. How much can you spend? Or, if you want to increase
your weekly food allowance of $25 by 25%, what is your new weekly allowance?
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Number
Percentage
25
25%
Formula
Description (Result)
=A2*(1-B2)
=A2*(1+B2)
=A2*(1+35%)
NOTE When you type a number followed by a percent sign (%), the number is
Round a number
Show All
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to round a number to the nearest whole number because decimal
values are not significant to you or round a number to multiples of 10 to simplify an
approximation of amounts. There are several ways to round a number.
Change the number of decimal places displayed, without changing the number
Round a number up
Round a number down
Round a number to the nearest number
Round a number to a near fraction
Round a number to a significant digit above 0
Round a number to a specified multiple
or Decrease
Round a number up
To do this task, use the ROUNDUP, EVEN, or ODD functions.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
Data
20.3
3
-5.9
4
12.5493
Formula
Description (Result)
=ROUNDUP(A2,0)
=ROUNDUP(A3,0)
=ROUNDUP(A4,2)
=EVEN(A2)
=ODD(A2)
Function details
ROUNDUP
EVEN
ODD
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
20.3
3
-5.9
4
12.5493
Formula
Description (Result)
=ROUNDDOWN(A2,0)
=ROUNDDOWN(A3,0)
=ROUNDDOWN(A4,2)
Rounds the number down to the nearest hundredth, two decimal places ( 12.54)
Functions details
ROUNDDOWN
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
3
4
20.3
5.9
-5.9
Formula
Description (Result)
=ROUND(A2,0)
Rounds 20.3 down, because the fractional part is less than .5 (20)
=ROUND(A3,0)
Rounds 5.9 up, because the fractional part is greater than .5 (6)
=ROUND(A4,0)
Rounds -5.9 down, because the fractional part is less than -.5 (-6)
Function details
ROUND
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
1.25
3
30.452
Formula
Description (Result)
=ROUND(A2,1)
Rounds the number to the nearest tenth (one decimal place). Because the portion to be rounde
0.05 or greater, the number is rounded up (result: 1.3)
=ROUND(A3,2)
Rounds the number to the nearest hundredth (two decimal places). Because the portion to be
rounded, 0.002, is less than 0.005, the number is rounded down (result: 30.45)
Functions details
ROUND
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
5492820
3
22230
Formula
Description (Result)
=ROUND(A2,3-LEN(INT(A2)))
=ROUNDDOWN(A3,3-LEN(INT(A3)))
=ROUNDUP(A2,5-LEN(INT(A2)))
Function details
ROUNDUP
ROUNDDOWN
ROUND
LEN, LENB
INT
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=MROUND(16, 5)
=MROUND(-16, -5)
=MROUND(2.6, 0.08)
=MROUND(5, -2)
3
4
5
Show All
Let's say you want to calculate an extremely small tolerance level for a machined part or
the vast distance between two galaxies. To raise a number to a power, use the "^"
operator or the POWER function.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=POWER(5,2)
=5^3
Let's say you want to find out who has the the smallest error rate in a production run at
a factory or the largest salary in your department. There are several ways to calculate the
smallest or largest number in a range.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
10
3
7
4
5
27
0
4
Formula
Description (Result)
=MIN(A2:A7)
=MAX(A2:A7)
=SMALL(A2:A7, 2)
=LARGE(A2:A7,3)
Let's say you have six bells, each with a different tone, and you want to find the number
of unique sequences in which each bell can be rung once. In this example, you are
calculating the factorial of six. In general, use a factorial to count the number of ways in
which a group of distinct items can be arranged (also called permutations). To calculate
the factorial of a number, use the FACT function.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
6
Formula
Description (Result)
=FACT(A2)
=FACT(3)
=FACT(A2+4)
Factorial of 10 (3628800)
Let's say you want to help your daughter better understand math concepts by
dynamically creating a multiplication table. You can use a two-variable data table.
1. Set up a worksheet with the following structure.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
1
1
3
=A1*A2
2. Enter a row of values from B3 to the right, for example, 1 through 10.
3. Enter a column of values from A4 down, for example, 1 through 10.
4. Select all cells in the range except cells A1 and A2.
5. On the Data menu, click Table.
6. In the Row input cell box, enter A1.
7. In the Column input cell box, enter A2.
8. Click OK.
9. Optionally, you can freeze the data table by converting the result to their values.
Let's say you want to count only rows that contain numbers and dates in a column that
contains a mix of different data types. There are several ways to count cells that contain
numbers.
ENTER.
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
Sales
3
12/8/2007
4
5
19
6
22.44
Formula
Description (Result)
=COUNT(A2:A6)
Counts number of cells that contain numbers (3) in the list. A date is a number.
=COUNT(A2:A3,A6)
Counts number of cells that contain numbers (2), of the top two and bottom cells in the list
date is a number.
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to find out how many people entered project hours this week or how
many products sold on a specific day. To count nonblank cells, use the COUNTA
function.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
Sales
3
4
5
6
19
TRUE
Formula
Description (Result)
=COUNTA(A2:A6)
=COUNTA(A2:A3, A6)
Counts the number of nonblank cells in the top two, and bottom cell in the list (1)
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to find out how many times particular text or a number value occurs.
For example:
If a range contains the number values 5, 6, 7, and 6, then the number 6 occurs two times.
If a column contains "Buchanan", "Dodsworth", "Dodsworth", and "Dodsworth", then "Dodsworth"
occurs three times.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
Salesperson
Invoice
Buchanan
15,000
Buchanan
9,000
Suyama
8,000
Suyama
20,000
Buchanan
5,000
Dodsworth
22,500
Formula
Description (Result)
=COUNTIF(A2:A7,"Buchanan")
=COUNTIF(A2:A7,A4)
=COUNTIF(B2:B7,"< 20000")
=COUNTIF(B2:B7,">="&B5)
1
2
3
4
5
Function details
COUNTIF
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
Region
Salesperson
Type
South
Buchanan
Beverages
West
Davolio
Dairy
East
Suyama
Beverages
North
Suyama
Dairy
South
Dodsworth
Produce
South
Davolio
Meat
South
Davolio
Meat
East
Suyama
Produce
North
Davolio
Produce
South
Dodsworth
Meat
Formula
Description (result)
1
2
3
4
5
8
9
10
11
=COUNT(IF((A2:A11="South")*(C2:C11="Meat"),D2:D11))
=COUNT(IF((B2:B11="Suyama")*(D2:D11=>1000),D2:D11))
NOTES
The formulas in the example must be entered as array formulas. After copying the example to a
blank worksheet, select the formula cell. Press F2, and then press CTRL+SHIFT+ENTER. If the formula
is not entered as an array formula, the error #VALUE! is returned.
For these formulas to work, the second argument to the IF function must be a number.
Function details
COUNT
IF
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Salesperson
Invoice
Buchanan
15,000
Buchanan
9,000
Suyama
8,000
Suyama
20,000
Buchanan
5,000
Dodsworth
22,500
Formula
Description (Result)
=SUM(IF((A2:A7="Buchanan")+(A2:A7="Dodsworth"),1,0))
=SUM(IF((B2:B7<9000)+(B2:B7>19000),1,0))
=SUM(IF(A2:A7="Buchanan",IF(B2:B7<9000,1,0)))
3
4
5
6
7
NOTE The formulas in this example must be entered as array formulas. Select each cell
Function details
IF
SUM
TOP OF PAGE
counting them. To change from the Sum summary function to the Count summary
function, on the PivotTable toolbar, click Field Settings
the Summarize by box, click Count.
, and then in
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to find out how many unique values exist in a range that contains
duplicate values. For example, if a column contains:
The values 5, 6, 7, and 6, then the result is three unique values5 , 6 and 7.
The values "Buchanan", "Dodsworth", "Dodsworth", "Dodsworth", then the result is two unique
values"Buchanan" and "Dodsworth".
The unique values from the selected range are copied to the new column.
7. In the blank cell below the last cell in the range, enter the ROWS function. Use the range of unique
values that you just copied as the argument. For example, if the range of unique values is B1:B45,
then enter:
=ROWS(B1:B45)
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Data
Data
986
Buchanan
Dodsworth
563
67
789
3
4
5
235
6
7
Buchanan
Dodsworth
689
789
Dodsworth
143
56
237
8
9
10
67
235
Formula
Descriptio
n (Result)
=SUM(IF(FREQUENCY(A2:A10,A2:A10)>0,1))
Count the
nu mber of
unique
number
values in
cells
A2:A10,
but do not
count
blank cells
or text
values (4)
=SUM(IF(FREQUENCY(MATCH(B2:B10,B2:B10,0),MATCH(B2:B10,B2:B10,0))>0,
1))
Count the
number of
unique
text and
number
values in
cells
B2:B10
(which
must not
contain
blank cells)
(7)
=SUM(IF(FREQUENCY(IF(LEN(A2:A10)>0,MATCH(A2:A10,A2:A10,0),""),
IF(LEN(A2:A10)>0,MATCH(A2:A10,A2:A10,0),""))>0,1))
Count the
number of
unique
text and
number
values in
cells
A2:A10 ,
but do not
count
blank cells
or text
values (6)
NOTES
The formulas in this example must be entered as array formulas. Select each cell that contains a
formula, press F2, and then press CTRL+SHIFT+ENTER.
To see a function evaluated step by step, select the cell containing the formula. Then, on
the Tools menu, point to Formula Auditing and click Evaluate Formula.
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
To count numbers greater than or less than a number, use the COUNTIF function. To
count numbers that fall between a range of numbers, you can use
the SUMPRODUCT function.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group,
click the Show Formulas button.
Salesperson
Invoice
Buchanan
15,000
Buchanan
9,000
Suyama
8,000
Suyama
20,000
Buchanan
5,000
Dodsworth
22,500
Formula
Description (Result)
=COUNTIF(B2:B7,">9000")
=COUNTIF(B2:B7,"<=9000")
=SUMPRODUCT((B2:B7>=9000)*(B2:B7<=22500))
1
2
3
4
5
Function details
The COUNTIF function counts the number of cells within a range that meet a single
criterion (condition) that you specify.
=COUNTIF(range, criteria)
The SUMPRODUCT function can be used to count numbers by specifying multiple
ranges and multiple criteria. In the example, B2:B7 is the range used for each criterion,
which are >=9000 and B2:B7<=22500.
Show All
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
2
Product
Description
Running total
Sandbox
Beach toys
Hardly used
=1+C2
Swing set
=1+C3
3
4
NOTE A running total differs from a running balance, in which you watch the sum of
values grow as new entries are added. For more information, see Calculate a running
balance.
Let's say you want to determine the size of a large spreadsheet to decide whether to use
manual or automatic calculation in your workbook. To count all of the cells in a range,
use a formula that multiplies the return values from the ROWS and COLUMNS functions.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Data
Data
Data
Data
15,000
28,500
55,000
87,000
9,000
13.700
63,800
23,000
8,000
1000
19,000
99,900
Formula
Description
(Result)
=ROWS(A1:D4) *
COLUMNS(A1:D4)
The total
number of
cells in the
range (16)
3
4
APPLIES TO
Microsoft Office Excel 2003
Microsoft Excel 2002
Count the number of words in a cell
You can count the number of words in a cell by using the following formula:
=IF(LEN(TRIM(A1))=0,0,LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))+1)
NOTE To avoid a circular reference, make sure you enter the formula in a cell outside
NOTES
To avoid a circular reference, make sure you enter the formula in a cell outside the range for which
you are counting the words.
To enter an array formula, select the cell that contains the formula, press F2, and then press
CTRL+SHIFT+ENTER.
In this example, imagine that cells A1 to D7 contain the words you want to count. To get
the total number of words in the specified range, the array formula counts the words in
each cell of that range, and the SUM function then adds up the values for each cell to
get the total.
Convert times
Show All
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to find out how many hours there are in five and a half days, or how
many days there are in 3.45 years, or how many months have passed between a
beginning date and an ending date. There are several ways to convert times.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
6
Formula
Description (Result)
=CONVERT(A2,"day","hr")
=CONVERT(A2,"hr","mn")
=CONVERT(A2,"yr", "day")
Function details
CONVERT
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
Time
10:35 AM
12:15 PM
Formula
Description (Result)
=(A2-INT(A2))*24
=(A3-INT(A3))*24
Function details
INT
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Hours
10.5833
3
12.25
Formula
Description (Result)
=TEXT(A2/24, "h:mm")
=TEXT(A3/24, "h:mm")
NOTE You can also apply the time number format without using the TEXT function to
specify the format. To view the number as a time, select the cell and click Cells on
the Format menu. Click the Number tab, and then click Time in the Category box.
However, if you use both a format applied with the TEXT function and number format,
Occasionally, dates may become formatted and stored in cells as text. For example, you
may have entered a date in a cell that was formatted as text, or the data might have
been imported or pasted from an external data source as text.
Dates that are formatted as text are left-aligned instead of right-aligned in a cell. With
Error Checking turned on, text dates with two-digit years might also be marked with an
error indicator
.
Because Error Checking in Microsoft Excel can identify text-formatted dates with twodigit years, you can use the automatic correction options to convert them to dateformatted dates. You can use the DATEVALUE function to convert most other types of
text dates to dates.
The DATEVALUE function returns the serial number of the date that is represented by
the text date.
What is a serial number?
3. To copy the conversion formula into a range of contiguous cells, select the cell in which you typed
the formula, and then drag the fill handle
the range of cells that contain text dates.
After you drag the fill handle, you should have a range of cells with serial numbers that
corresponds to the range of cells that contain text dates.
4. Select the cell or range of cells that contains the serial numbers, and then click Copy on
the Edit menu.
5. Select the cell or range of cells that contains the text dates, and then click Paste Special on
the Edit menu.
6. In the Paste Special dialog box, under Paste, click Values, and then click OK.
7. On the Format menu, click Cells.
8. On the Number tab, in the Category box, click Date, and then click a date style in the Type box.
Tip
You can now delete the cells that contain the serial numbers.
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Occasionally, numbers may be formatted and stored in cells as text, which later can
cause problems with calculations or produce confusing sort orders. For example, you
may have typed a number in a cell that was formatted as text, or the data may have
been imported or copied as text from an external data source.
Numbers that are formatted as text are left-aligned instead of right-aligned in the cell.
With error checking turned on, they are also marked with an error indicator
.
You can convert them to numbers in one cell or rangeof cells at a time, or in multiple
nonadjacent cells or ranges of cells all at once.
, and then
Tip If all the numbers are converted successfully, you can delete the content of the cell
that you typed in Step 2.
NOTE Some accounting programs display negative values with the negative sign () to
the right of the value. To convert the text strings to values, you must return all of the
characters of the text string except the rightmost character (the negation sign), and then
multiply the result by 1. For example, if the value in cell A2 is "156" the following
formula converts the text to the value 156.
DATA
FORMULA
156-
=LEFT(A2,LEN(A2)-1)*-1
Convert measurements
Show All
Let's say you want to know how many kilometers that you ran on a quarter-mile track or
a tolerance level using metric values. To convert measurements, use the CONVERT
function. The CONVERT function converts a wide range of measurements, including
measures of weight, distance, time, pressure, force, energy, power, magnetism,
temperature, and liquid measure.
If the CONVERT function is not available, install and load the Analysis ToolPak add-in.
How?
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
6
Formula
Description (Result)
=CONVERT(A2,"C","F")
=CONVERT(A2,"tsp","tbs")
=CONVERT(A2,"gal","l")
=CONVERT(A2,"mi","km")
=CONVERT(A2,"km","mi")
=CONVERT(A2,"in","ft")
=CONVERT(A2,"cm","in")
NOTE To see a full list of all the measures that can be converted, see the CONVERT
NUMBER SYSTEM
BASE VALUE
Binary
0,1
Octal
0, 1, 2, 3, 4, 5, 6, 7
Decimal
10
0, 1, 2, 3, 4, 5, 6, 7, 8, and 9
Hexadecimal
16
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=BIN2DEC(1100100)
=BIN2DEC(1111111111)
Function details
BIN2DEC
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=BIN2HEX(11111011, 4)
=BIN2HEX(1110)
=BIN2HEX(1111111111)
Function details
BIN2HEX
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=BIN2OCT(1001, 3)
=BIN2OCT(1100100)
=BIN2OCT(1111111111)
3
4
Function details
BIN2OCT
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=DEC2BIN(9, 4)
=DEC2BIN(-100)
Function details
DEC2BIN
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=DEC2HEX(100, 4)
=DEC2HEX(-54)
Function details
DEC2HEX
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=DEC2OCT(58, 3)
=DEC2OCT(-100)
Function details
DEC2OCT
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=HEX2BIN("F", 8)
=HEX2BIN("B7")
=HEX2BIN("FFFFFFFFFF")
3
4
Function details
HEX2BIN
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=HEX2DEC("A5")
3
4
=HEX2DEC("FFFFFFFF5B")
=HEX2DEC("3DA408B9")
Function details
HEX2DEC
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=HEX2OCT("F", 3)
=HEX2OCT("3B4E")
=HEX2OCT("FFFFFFFF00")
3
4
Function details
HEX2OCT
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=OCT2BIN(3, 3)
=OCT2BIN(7777777000)
Function details
OCT2BIN
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
3
Formula
Description (Result)
=OCT2DEC(54)
=OCT2DEC(7777777533)
Function details
OCT2DEC
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Formula
Description (Result)
=OCT2HEX(100, 4)
=OCT2HEX(7777777533)
Let's say you want to change an Arabic numeral to a Roman numeral for special
emphasis in a party invitation or promotional flyer. To convert Arabic to Roman
numerals, use the ROMAN function.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
Formula
Description (Result)
=ROMAN(499,0)
=ROMAN(499,1)
=ROMAN(499,2)
=ROMAN(499,3)
=ROMAN(499,4)
=ROMAN(2013,0)
1
2
3
4
5
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
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.
Name
nancy Davolio
Formula
Description (Result)
=UPPER(A2)
=LOWER(A2)
=PROPER(A2)
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to ensure that a column contains text and not numbers or you want
to find all orders by a particular salesperson. There are several ways to check if a cell
contains text but the case of the text doesn't matter to you.
In the Within box, you can select Sheet or Workbook to search a worksheet or an
entire workbook.
6. Click Find All or Find Next.
Find All lists every occurrence of the item that you are searching for and allows you to
make a cell active by selecting a specific occurrence. You can sort the results of a Find
All search by clicking a header.
NOTE To cancel a search in progress, press ESC.
Tip To find data in a list, you can use filters to display only the rows that contain the
desired data. For example, in a list that includes international sales data, you can display
just domestic sales.
TOP OF PAGE
4. In the box on the left, click equals, or does not equal, contains, or does not contain.
5. In the box on the right, enter the text that you want.
6. If you need to find text values that share some characters but not others, use a wildcard character.
How?
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
Davolio
3
123
Formula
Description
=ISTEXT(A2)
=ISTEXT(A3)
Function details
ISTEXT
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
Davolio
Formula
Description
Function details
IF
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
Davolio
3
BD123
Formula
Description (Result)
=ISNUMBER(SEARCH("BD",A3))
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Let's say you want to find text that begins with a standard company prefix, such as ID_
or EMP-, and this text must be in uppercase letters. There are several ways to check if a
cell contains text and the case of the text matters to you.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
Data
BD122
3
BD123
4
BD123
Formula
Description (Result)
=EXACT(A2,A3)
=EXACT(A3,A4)
Function details
EXACT
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
List
Cell
Apple
Grape
3
Orange
4
Banana
Formula
Description (Result)
=OR(EXACT(B2, A2:A4))
NOTE The formula in the example must be entered as an array formula. After copying
the example to a blank worksheet, select each formula cell individually. Press F2, and
then press CTRL+SHIFT+ENTER. If the formula is not entered as an array formula, the
error #VALUE! is returned.
Function details
OR
EXACT
TOP OF PAGE
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
Davolio
3
BD123
Formula
Description (Result)
=ISNUMBER(FIND("BD",A3))
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.
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
12 as Product #12
"Product # " 0
$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
1
2
Salesperson
Sales
Buchanan
28
Dodsworth
40%
Formula
Description (Result)
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.
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
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
Billing Date
3
5-Jun-2007
Formula
Description (Result)
Combine text and date from difference cells into one cell (Billing Dat
Jun-05-2007)
NOTE To copy the number format code used in a cell into the formula, select the cell,
then click Cells on theFormat menu. Click the Number tab. In the Category box,
click Custom, and then copy the contents of theType box.
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
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
2
First Name
Last Name
Nancy
Davolio
Andrew
Fuller
Formula
Description (Result)
=A2&" "&B2
=B3&", "&A3
=CONCATENATE(A2," ",B2)
NOTE
To replace the formula with the results, select the cells, click Copy
click Paste
, click PasteOptions
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
NOTE To see the result without breaking the lines of the name or
First name
Last name
Street
address
City
State
Zip
co
Robert
Walters
4567
Main St.
Buffalo
NY
98
Function
Description
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
2
Formula
Description (Result)
=REPT(".",6)
=REPT("-",4)
Let's say, for common security measures, you want to display only the last four digits of
an identification or Social Security number, credit card number, or other number and
replace the rest of the digits with asterisks. Whether the digits in your cell are formatted
as text, numbers, or the special Social Security number format, you can use the same
functions. To display only the last four digits of identification numbers, use the
CONCATENATE, RIGHT, and REPT functions.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
1
2
Type
Data
555-55-5555
5555-5555-5555-5555
Formula
Description (Result)
=CONCATENATE("***-**-",
RIGHT(B2,4))
Combines the last four digits of the SSN with the "***-**-" text string (**
**-5555)
=CONCATENATE(REPT("****-",3),
RIGHT(B3,4))
Repeats the "****-" text string three times and combines the result with
the the last four digits of the credit card number w(****-****-****-555
SECURITY In the example, you should hide column B and protect the worksheet so that
the original data cannot be viewed. For more information, see Hide or display rows and
columns and Protect worksheet or workbook elements.
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
Sometimes text values contain leading, trailing, or multiple embedded space characters
(Unicode character setvalues 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
typographical errors by inadvertently adding extra space characters, or imported text
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. 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, . 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.
Data
BD 122
3
="XY"&CHAR(7)&"453"
4
5
BD 122
MN987
Formula
Description (Result)
=TRIM(A2)
Removes the trailing space from the string "BD 122 " (BD 112)
=CLEAN(A3)
=TRIM(SUBSTITUTE(A4,CHAR(160),CHAR(32)))
=CLEAN(SUBSTITUTE(A5,CHAR(127),CHAR(7)))
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
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.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
Vitamin A
3
Vitamin B1
Formula
Description (Result)
=LEFT(A2, LEN(A2)-2)
=RIGHT(A3, LEN(A3)-8)
Function details
LEN, LENB
LEFT, LEFTB
RIGHT, RIGHTB
TOP OF PAGE
In the Within box, you can select Sheet or Workbook to search a worksheet or an
entire workbook.
6. 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.
7. Click Find Next.
8. 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.
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
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.
Important notice for users of Office 2003 To continue receiving security updates for
Office, make sure you're running Office 2003 Service Pack 3 (SP3). The support for Office
2003 ends April 8, 2014. If youre running Office 2003 after support ends, to receive all
important security updates for Office, you need to upgrade to a later version such as
Office 365 or Office 2013. For more information, see Support is ending for Office 2003.
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.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1
2
Data
Vitamin A
3
Vitamin B1
Formula
Description (Result)
=LEFT(A2, LEN(A2)-2)
=RIGHT(A3, LEN(A3)-8)
Function details
LEN, LENB
LEFT, LEFTB
RIGHT, RIGHTB
TOP OF PAGE
5. 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.
6. 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.
7. Click Find Next.
8. To replace the highlighted occurrence or all occurrences of the found characters,
click Replace or Replace All.
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
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.