You are on page 1of 17

Add numbers in a cell

To do this task, use the + (plus sign) arithmetic operator.


For example, if you type the following formula in a cell:
=5+10
The cell displays the following result:
15

Add all contiguous numbers in a


row or column
To do this task, use AutoSum

1.

Click a cell below the column of numbers or to the right of the row of numbers.

2.

Click AutoSum

on the Standard toolbar, and then press ENTER.

TOP OF PAGE

Add noncontiguous numbers


To do this task, use the SUM function.
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

Suyama

8,000

Suyama

20,000

Buchanan

5,000

Dodsworth

22,500

Formula

Description (Result)

3
4
5
6
7
=SUM(B2:B3, B5)Adds two invoices from Buchanan, and one from Suyama (44,000)
=SUM(B2,B5,B7) Adds individual invoices from Buchanan, Suyama, and Dodsworth
(57,500)

NOTE

The SUM function can include up to 30 cell or range references.

Function details
SUM
TOP OF PAGE

Add numbers based on one


condition
You can use the SUMIF function to create a total value for one range based on a value in
another range, as in the following example.
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)

=SUMIF(A2:A7,"Buchanan",B2:B7)Sum of invoices for Buchanan (29000)


=SUMIF(B2:B7,">=9000",B2:B7)

Sum of large invoices greater than or equal to 9,000


(66500)

=SUMIF(B2:B7,"<9000",B2:B7)

Sum of small invoices less than 9,000 (13000)

The SUMIF function uses the following arguments

Add numbers based on multiple


conditions
To do this task, use the IF and SUM functions.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example

Region

Salesperson

Type

Sale
s

South

Buchanan

Beverage 3571
s

West

Davolio

Dairy

East

Suyama

Beverage 5122
s

North

Suyama

Dairy

6239

South

Dodsworth

Produce

8677

South

Davolio

Meat

450

South

Davolio

Meat

7673

East

Suyama

Produce

664

North

Davolio

Produce

1500

South

Dodsworth

Meat

6596

Formula

Description (Result)

3338

3
4
5
6
7
8
9
10
11

=SUM(IF((A2:A11="South")*(C2:C11="Meat"),D2:D11)) Sum of Meat sales in the


South region (14719)
=SUM(IF((A2:A11="South")+(A2:A11="East"),D2:D11)) Sum of sales where the
region is South or East
(32753)

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

Add numbers based on criteria


stored in a separate range

To do this task, use the DSUM function.


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

Sale
s

South

Buchanan

Beverage 3571
s

West

Davolio

Dairy

East

Suyama

Beverage 5122
s

North

Suyama

Dairy

6239

South

Dodsworth

Produce

8677

South

Davolio

Meat

450

South

Davolio

Meat

7673

East

Suyama

Produce

664

North

Davolio

Produce

1500

South

Dodsworth

Meat

6596

Region

Salesperson

Type

Sale
s

1
2
3

3338

6
7
8
9
10
11

South

Meat
Produce

Formula

Description (Result)

=DSUM(A1:D11, "Sales",
A12:D13)

Sum of Meat sales in the South region (14719)

=DSUM(A1:D11, "Sales",
A12:D14)

Sum of Meat and Produce sales in the South


region (25560)

The DSUM function uses the following arguments.

Calculate the smallest or largest number in a range

If the cells are in a contiguous row or column


1.

Select a cell below or to the right of the numbers for which you want to find the
smallest number.

2.

Click the arrow next to AutoSum


, and then click Min (calculates the smallest), or
Max (calculates the largest), and then press ENTER.

If the cells are not in a contiguous row or


column
Count cells that contain numbers

1.
2.

Count cells that contain numbers in a


contiguous row or column

Select a cell below or to the right of the numbers that you want to count.

Click the arrow next to the AutoSum


Count and press ENTER.

on the Standard toolbar, and then click

TOP OF PAGE

Count cells that contain numbers that are not


in a contiguous row or column
To do this task, use the COUNT function.
Example
The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example


A
Data
Sales
1
12/8/2007
2
3
4
5
6

19
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. A date is a number.

Count nonblank cells

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

19

TRUE

Formula

Description (Result)

=COUNTA(A2:A6)

Counts the number of nonblank cells in the list above (3)

=COUNTA(A2:A3, A6) Counts the number of nonblank cells in the top two, and bottom cell in the list
(1)

Count how often a value occurs

Count how often a single value occurs by


using a function
Use the COUNTIF function to perform this task.
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
4
5
6
7

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")Number of entries for Buchanan (3)


=COUNTIF(A2:A7,A4)

Number of entries for Suyama (2)

=COUNTIF(B2:B7,"< 20000") Number of invoice values less than 20,000 (4)


=COUNTIF(B2:B7,">="&B5)

Number of invoice values greater than or equal to 20,000


(2)

Count numbers greater than or less than a number


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.
A
1
2
3
4
5
6
7

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")

Numbers above 9000 (3)

=COUNTIF(B2:B7,"<=9000")

Numbers less than or equal to 9000 (3)

=SUMPRODUCT((B2:B7>=9000)*(B2:B7<=22500))The SUMPRODUCT function counts the number


of cells in the range B2:B7 that contain numbers
greater than or equal to 9000 and less than or
equal to 22500 (4).
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.

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 6 degrees Celsius to Fahrenheit


(42.8)

=CONVERT(A2,"tsp","tbs") Convert 6 teaspoons to tablespoons (2)


=CONVERT(A2,"gal","l")

Convert 6 gallons to liters (22.71741274)

=CONVERT(A2,"mi","km") Convert 6 miles to kilometers (9.656064)


=CONVERT(A2,"km","mi") Convert 6 kilometers to miles (3.728227153)
=CONVERT(A2,"in","ft")

Convert 6 inches to feet (0.5)

=CONVERT(A2,"cm","in") Convert 6 centimeters to inches


(2.362204724)

Convert between time units


To do this task, use the CONVERT function.
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
Data
6

1
2

Formula

Description (Result)

=CONVERT(A2,"day","hr") Convert 6 days to hours (144)


=CONVERT(A2,"hr","mn") Convert 6 hours to minutes
(360)
=CONVERT(A2,"yr", "day") Convert 6 years to days
(2191.5)

NOTE For conversions using a year, a year is treated as 365.25 days.

Compare one cell to another cell


To do this task, use the EXACT function.
Example
The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example


A
Data
BD122
1
BD123
2
BD123
3
Formula

Description (Result)

4
=EXACT(A2,A3)Compare contents of A2 and A3 (FALSE)
=EXACT(A3,A4)Compare contents of A3 and A4 (TRUE)

NOTE EXACT is case-sensitive but ignores formatting differences.

Compare one value to a list of


values
To do this task, use the EXACT and OR functions.
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
4

List

Cell

Apple

Grape

Orange
Banana
Formula

Description (Result)

=OR(EXACT(B2, A2:A4)) Compares "Grape" to each value in the list


(FALSE)

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.

Combine two or more columns by using a function

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 address, expand the
width of column A to at least 17.00 units or 124 pixels.
A

First name

Last name

Street
City
address

Robert

Walters

4567
Buffal NY
Main St. o

Function

Description

Stat Zip
e
code

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

Calculate the average of numbers not in a


contiguous row or column

98052

To do this task, use the AVERAGE function.


Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
Data
10
1

27

4
5
6
7

0
4
Formula

Description (Result)

=AVERAGE(A2:A7)

Averages all of numbers in list above (9.5)

=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 A6 (11.4)

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

Calculate a weighted average


To do this task, use the SUMPRODUCT and SUM functions.
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.
A

Price per unit

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 units ordered (24.66)

Calculate the average of numbers, ignoring


zero (0) values
To do this task, use the AVERAGE and IF functions.
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

27

0
4
7

Formula

Description (Result)

=AVERAGE(IF(A2:A7<>0,
A2:A7,""))

Averages the numbers in the list except those that contain zero,
such as cell A6 (11.4)

Create conditional formulas


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.

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.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
A
1

Data

15

8
Sprockets

Widgets
Formula

Description (Result)

=AND(A2>A3, A2<A4)

Is 15 greater than 9 and less than 8? (FALSE)

=OR(A2>A3, A2<A4)

Is 15 greater than 9 or less than 8? (TRUE)

=NOT(A2+A3=24)

Is 15 plus 9 not equal to 24? (FALSE)

=NOT(A5="Sprockets")

Is A5 not equal to "Sprockets"? (FALSE)

=OR(A5<>"Sprockets",A6 =
"Widgets")

Is A5 not equal to "Sprockets" or A6 equal to "Widgets"?


(TRUE)

You might also like