Sunteți pe pagina 1din 5

# Countif=Counts the number of cells within a range that meet the given criteria.

Syntax : COUNTIF(range,criteria) Range is the range of cells from which you want to count cells. Criteria is the criteria in the form of a number, expression, cell reference, or text that defines which cells will be counted. For example, criteria can be expressed as 32, "32", ">32", "apples", or B4. Remarks

You can use the wildcard characters, question mark (?) and asterisk (*), in criteria. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character. Microsoft Excel provides additional functions that can be used to analyze your data based on a condition. To calculate a sum based on a string of text or a number within a range, use the SUMIF worksheet function. To have a formula return one of two values based on a condition, such as a sales bonus based on a specified sales amount, use the IF worksheet function. To count cells that are empty or not empty, use the COUNTA and COUNTBLANK functions.

## The example may be easier to understand if you copy it to a blank worksheet

A 1 2 3 4 5 oranges peaches apples Formula =COUNTIF(A2:A5,"apples") =COUNTIF(A2:A5,A4) =COUNTIF(A2:A5,A3)+COUNTIF(A2:A5,A2) 54 75 86 Description (result) Data apples B Data 32

## Number of cells with apples in the first column above (

Number of cells with peaches in the first column above Number of cells with oranges or

## apples in the first column above (3) =COUNTIF(B2:B5,">55") =COUNTIF(B2:B5,"<>"&B4) =COUNTIF(B2:B5,">=32")COUNTIF(B2:B5,">85")

Number of cells with a value greater than 55 in the sec above (2)

Number of cells with a value not equal to 75 in the sec above (2)

Number of cells with a value greater than or equal to 3 than or equal to 85 in the second column above (3)

Example 2: COUNTIF formulas using wildcard characters and handling blank values
The example may be easier to understand if you copy it to a blank worksheet A 1 2 3 4 5 6 7 oranges peaches NO No Data apples B Data Yes

## apples Formula =COUNTIF(A2:A7,"*es") =COUNTIF(A2:A7,"?????es")

YeS Description (result) Number of cells ending with the letters "es" in the first column above (4) Number of cells ending with the letters "les" and having exactly 7 letters in the first column above (2) Number of cells containing text in the first Column above (4) Number of cells not containing text in the first column above (2) The average number of No votes including blank cells in the second column above formatted as a percentage with no decimal places (33%)

## =COUNTIF(B2:B7,"Yes") / (ROWS(B2:B7) -COUNTIF(B2:B7, "<>"&"*"))

The average number of Yes votes excluding blank cells in the second column above formatted as a percentage with no decimal places (50%)

To view the number as a percentage, select the cell and click Cells on the Format menu. Click theNumber tab, and then click Percentage in the Category box. IF FUNCTION-This article describes the formula syntax and usage of the IF function in Microsoft Office Excel. DESCRIPTION-The IF function returns one value if a condition you specify evaluates to
TRUE, and another value if that condition evaluates to FALSE. For example, the formula =IF(A1>10,"Over 10","10 or less") returns "Over 10" if A1 is greater than 10, and "10 or less" if A1 is less than or equal to 10. SYNTAX -IF(logical_test, value_if_true, [value_if_false]) The IF function syntax has the following arguments:

logical_test Required. Any value or expression that can be evaluated to TRUE or FALSE. For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100, the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE. This argument can use any comparison calculation operator. value_if_true Required. The value that you want to be returned if the logical_test argument evaluates to TRUE. value_if_false Optional. The value that you want to be returned if the logical_test argument evaluates to FALSE

=IF(A3>B3,"Over Budget","OK")

## A 1 2 3 Formula =IF(A2<=100,"Within budget","Over budget") Data 50

23 Description If the number in cell A2 is less than or equal to 100, the formula returns "Within budget." Otherwise, the function displays "Over budget."

Resu

With budg

=IF(A2=100,A2+B2,"") 5

If the number in cell A2 is equal to 100, A2 + B2 is calculated and returned. Otherwise, empty text ("") is returned.

Emp ("")

EXAMPLE 2
A 1 2 3 500 4 5 500 Formula 6 =IF(A2>B2,"Over Budget","OK") 7 Checks whether the expenses in row 2 are over budget 925 Description 900 Actual Expenses 1500 B Predicted Expenses 900