Вы находитесь на странице: 1из 5

Count and Sum Your Data in Excel 2002

Formulas for the Arsenal of Every Excel User

By John Walkenbach, Microsoft Most Valuable Professional (MVP) Counting and summing are basic spreadsheet operations and they can go a long way to helping you get the most out of Microsoft Excel version 2002. The summing and counting formulas in this article should be in the arsenal of every Excel user. The formulas are based on the worksheet in igure !. The !2 data rows in igure ! contain sales information for an average company" and consist of three fields# the sales representative" month of the sale" and amount of the sale. The examples of summing and counting formulas will demonstrate how a small company could analy$e this data. %our data may more extensive and collected for different purposes" but the formulas will work &ust the same. 'fter explaining the example formulas" we provide the result of the formulas based on the data in igure !.

Figure 1: Sa !le "#cel $orksheet

Summing and Counting


(etting the sum of numbers)be if for your budget" sales statistics" or inventory)is a common task. *se the +*M function in these instances. These formulas return the sum of the numbers in the C column#

Add values within a certain range: =SUM(C2:C13) Formula result: 6,125 Add values for an entire range: =SUM(C:C). New data is ofte added to a e!isti " ta#le, so t$e um#er of rows will %ar&. '$is formula adds u( t$e e tire )olum a d elimi ates t$e eed to edit &our formula w$e ew data is i serted.

or counting values" use the C,*-T function. .t returns the number of values in a range and can /uickly determine how many cells contain numeric information. This can be helpful" for example" when trying to determine how many months had sales.

Count values in a range: =C*UN'(C2:C13) Formula result: 12 Count values in the entire range: =C*UN'(C:C)

'lthough column C contains !0 entries" these formulas return !2 because the C,*-T function only counts numeric values. .f you need to count all the cells in a range that contain any information" use the C,*-T' function" such as# 1C,*-T'2'#'3. This formula will return a result of !0.

Conditional Counting and Summing Using a Single Condition


.n many cases" you don4t want to count or sum all of the records. 5ather" you want to focus on records that meet a certain condition" for example" only the sales made by a sales representative. *se the C,*-T. and +*M. functions to return these types of results. Count the Number of Sales Made by a Sales Representative The following formula is a straightforward use of the C,*-T. function. .t counts the sales made by 6ones#

=C*UN'+F(,2:,13,-.o es-) Formula result: /

%ou can also write this formula as# 1C,*-T. 2'2#'!0"716ones73. %ote: &f a co !arison o!erator is o itte', "#cel assu es (e)ual to*( Count the Number of Sales Made by Other Sales Representatives This formula counts all the sales not made by 6ones#

=C*UN'+F(,2:,13,-01.o es-) Formula result: 2

Count the Number of Sales Greater than a Target Value This formula counts the number of sales in C2#C!0 that are greater than a target value. .n this example" the target value would have to be entered into 8!. This C,*-T. function accepts a cell reference in the second argument. 'lso" notice that this formula uses the concatenation operator 293 to &oin the greater than symbol 2:3 with the cell reference.

=C*UN'+F(C2:C13,-1-341)

Count the Number of Sales Greater than the Sales Average This formula returns the number of sales that exceed the average sales amount. This formula also shows that you can use a function as the second argument for C,*-T. #

=C*UN'+F(C2:C13,-1-3,567,86(C2:C13)) Formula result: 5

Conditional Summing

The +*M. function is similar to C,*-T. " but it uses an additional argument. The first argument refers to the range that is being evaluated" the second argument represents the criteria" and the third argument is the range to be summed. Add Up Sales in a Given Month This formula adds up all the sales in 6anuary#

=SUM+F(92:913,-=.a -,C2:C13) Formula result: 1,:25

's with the C,*-T. function" an 7e/ual to7 condition is assumed if the comparison operator is omitted. The preceding formula could have been written as# 1+*M. 2;2#;!0"716an7"C2#C!03. Add Up Sales Made by Other Sales Representatives This formula adds up the sales made by sales representatives other than 5ogers. .t uses a 7not e/ual to7 comparison#

=SUM+F(,2:,13,-017o"ers-,C2:C13) Formula result: /,/25

Add Up the Sales Greater than a Certain Value This formula adds up all the values that are greater than <00. .n this formula" the condition being evaluated is based on the same range that is being summed#

=SUM+F(C2:C13,-15;;-,C2:C13) Formula result: /,/5;

Note# The C,*-T. and +*M. functions can also use wildcard comparison characters. or more information" in Excel =elp search for 7wildcard.7

Conditional Counting and Summing Using Multiple Conditions


The formulas in the section return counts or sums based on two or more conditions. Count the Number of Months a Sales Representative Made a Sale This formula counts the number of times 6ones made sales in ebruary. .t is a conditional counting formula that uses two conditions.

=SUM<7*4UC'((,2:,13=-.o es-)=(92:913=-Fe#-)) Formula result: 2

Table ! shows what4s going on behind the scenes. The first column shows the result of the first part of the argument. The second column shows the result of the second part of the argument. The last column shows the result of multiplying the first two columns. >hen both columns are T5*E" the result of multiplying similar values is !. The formula then returns the sum of these multiplications. ,2:,13=-.o es'rue 'rue False False False False

92:913=-Fe#False False False False False False

7esult of multi(li)atio
; ; ; ; ; ;

False 'rue False False False 'rue

'rue 'rue 'rue 'rue 'rue 'rue

; 1 ; ; ; 1

+able 1 Count Months hen Sales Are Greater than a Spe!ifi! Amount %ou can use a formula similar to the one above to work with numeric data. This formula returns the number of rows in which the month is 6anuary and the amount is greater than 200.

=SUM<7*4UC'((92:913=-.a -)=(C2:C1312;;)) Formula result: /

Count the Number of Sales that Are "et#een Spe!ifi! Values This formula counts the number of times the sales amount falls between two 200 and <00. The formula uses two conditions# the amount greater than or e/ual to 200" and the amount less than or e/ual to <00.

=SUM<7*4UC'((C2:C131=2;;)=(C2:C130=5;;)) Formula result: 5

Count the Number of Sales "ased on Three Conditions This formula returns the amount when the sales representative is 6ones" the month is ebruary" and the amount is greater than <00. This function uses a single argument" which consists of three logical expressions multiplied together. The result is the sum of these products.

=SUM<7*4UC'((,2:,13=-.o es-)=(92:913=-Fe#-)=(C2:C1315;;)) Formula result: 1

Add Up a Representative$s Sales in One Month The formula below adds up sales amount based on two conditions# when the sales representative is 6ones and the month is ebruary.

=SUM<7*4UC'((,2:,13=-.o es-)=(92:913=-Fe#-)=(C2:C13)) Formula result: 1,15;

Add the Combined Sales for T#o Sales Representatives The formula below returns the sum of the sales amount for both 6ones and 5ogers. This formula uses a single argument and consists of three expressions. -otice" however" that the first two arguments are not multiplied as in the previous examples. ;ecause we are doing a logical ,5 comparison" they are summed. +umming two logical values results in a value of ! when either of the expressions is T5*E.

=SUM<7*4UC'(((,2:,13=-.o es-)>(,2:,13=-7o"ers-))=(C2:C13)) Formula result: 3,1?5

NOTE:

Frequently Asked Questions


Question: I'm trying to use COUNTIF on a selection of cells (not necessarily one solid range ! and t"e synta# of t"e function does not allo$ t"at% Is t"ere anot"er $ay to do t"is& Here's an example of what I'd like to be able to do: 'COUNTIF(A(!A)!F*!+,!-./Ans$er: Unfortunately, the COUNTI fun!tion does not support multiple ran"es# Howe$er, you !ould try summin" multiple COUNTI s# or example: '0U1(COUNTIF(A(!-./- !COUNTIF(A)!-./- !COUNTIF(F*!-./- !COUNTIF(+,!-./O% 'COUNTIF(A(!-./- 2COUNTIF(A)!-./- 2COUNTIF(F*!-./- 2COUNTIF(+,!-./-

Question: I am using t"e COUNTIF function and I $ould like to make t"e criteria equal to a cell% or example: 'COUNTIF(C3:C4,!-.'(5(*5/3I want to repla!e &'&(')* with !ell +,# How do I do thisAns$er: To use a !ell referen!e in the !riteria, you !ould do the followin": 'COUNTIF(C3:C4,!-.'-6A4

Вам также может понравиться