This article is from the Spreadsheets FAQ, by Russell Schulz casfaq@locutus.ofB.ORG with numerous contributions by others.
use an array formula; in MS-Windows, you enter an array formula
with Ctrl+Shift+Enter. on a Mac, use Command+Shift+Enter (I think).
Excel will add {braces} to the display to remind you it's an array.
SUMIF() and COUNTIF() functions in recent versions of Excel can
be simpler, but reduce portability, and can't handle the more
complex cases.
examples: data is in rows 10:50
- count entries in column B that are >10
=SUM(IF(B10:B50>10,1,0))
- sum entries in column B that are >10
=SUM(IF(B10:B50>10,B10:B50,0))
- average entries in column B that are >10
=SUM(IF(B10:B50>10,B10:B50,0)) / SUM(IF(B10:B50>10,1,0))
- sum column A when column B is >10
=SUM(IF(B10:B50>10,1,0)*A10:A50)
- sum column A * column B when column C is "blue"
=SUM(IF(C10:C50="blue",1,0)*A10:A50*B10:B50)
- sum column A when column B is >10 and column C is "blue"
=SUM(IF(B10:B50>10,1,0)*IF(C10:C50="blue",1,0)*A10:A50)
[don't use AND(), see below]
- sum column A when column B is >10 or column C is "blue"
=SUM(SIGN(IF(B10:B50>10,1,0)+IF(C10:C50="blue",1,0))*A10:A50)
[don't use OR(), see below]
 
Continue to: