## Use IF + COUNTIF to evaluate multiple conditions

The image above demonstrates a formula that matches a value to multiple conditions, if the condition is met the formula takes the value in a corresponding cell on the same row and adds a given number.

**Table of contents**

The COUNTIF function allows you to construct a small IF formula thatÂ carries out plenty of logical expressions.

Combining the IF and COUNTIF functions also let you have more than 254 logical expressions and the effort to type the formula is minimal.

## 1. Use IF + COUNTIF to evaluate multiple conditions

The example shown in the above picture checks if the country in cell B3 is equal to one of the countries in cell range B23:D25.

In other words, the COUNTIF function counts how many times a specific value is found in a cell range.

If the value exists at least once in the cell range the IF function adds 100 to the value in C3. If FALSE the formula returns a blank.

### 1.1 Explaining formula in cell D3

#### Step 1 - COUNTIF function syntax

The COUNTIF function calculates the number of cells that is equal to a condition.

COUNTIF(*range*,Â *criteria*)

#### Step 2 - Populate COUNTIF function arguments

COUNTIF(*range*,Â *criteria*)

becomes

COUNTIF($B$23:$D$25,B3)

*range *- A reference to all conditions: $B$23:$D$25

*criteria -Â *The value to match.

#### Step 3 - Evaluate COUNTIF function

COUNTIF($B$23:$D$25,B3)

becomes

COUNTIF({"**Cambodia**", "Sri Lanka", "Japan"; "Mongolia", "Bangladesh", "Philippines"; "Laos", "India", "Indonesia"}, "**Cambodia**")

and returns 1. The criteria value is found once in the array (bolded).

#### Step 4 - IF function syntax

The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.

IF(*logical_test, [value_if_true], [value_if_false]*)

#### Step 5 - Populate IF function arguments

IF(*logical_test, [value_if_true], [value_if_false]*)

becomes

IF(1, C3+100, "")

*logical_testÂ *- True or False, the numerical equivalents are TRUE - 1 and False - 0 (zero). 1, in this case, is equal to TRUE.

*[value_if_true] *- C3+100, add 100 to value in cell C3.

* [value_if_false] *- "".

#### Step 6 - Evaluate IF function

IF(COUNTIF($B$23:$D$25, B3), C3+100, "")

becomes

IF(1, C3+100, "")

becomes

C3 + 100

becomes

99 + 100

and returns 199 in cell D3.

## 2. Use IF + COUNTIF to evaluate multiple conditions and calculate different outcomes

The image above demonstrates a formula in cell D3 that checks if the value in cell B3 matches any of the conditions specified in cell range F4:F12. If so, add the corresponding number in cell range G4:G12 to the number in cell C3.

Formula in cell D3:

### 2.1 Explaining formula

#### Step 1 - Check if the value matches any of the conditions

The COUNTIF function calculates the number of cells that is equal to a condition.

COUNTIF(*range*,Â *criteria*)

COUNTIF($F$4:$F$12, B3)

becomes

COUNTIF({"**Cambodia**"; "Mongolia"; "Laos"; "Sri Lanka"; "Bangladesh"; "India"; "Japan"; "Philippines"; "Indonesia"}, "**Cambodia**")

and returns 1. This means that there is one value that matches.

#### Step 2 - IF function

The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.

IF(*logical_test, [value_if_true], [value_if_false]*)

IF(COUNTIF($F$4:$F$12, B3), *[value_if_true]*, *[value_if_false]*)

becomes

IF(1, *[value_if_true]*, *[value_if_false]*)

*[value_if_true]Â *- C3+INDEX($G$4:$G$12, MATCH(B3, $F$4:$F$12,0))

*[value_if_false]Â *- ""

#### Step 3 - Calculate the relative position of a lookup value

The MATCH function returns the relative position of an item in an array or cell reference that matches a specified value in a specific order.

MATCH(*lookup_value*, *lookup_array*, *[match_type]*)

MATCH(B3, $F$4:$F$12,0)

becomes

MATCH("Cambodia", {"Cambodia"; "Mongolia"; "Laos"; "Sri Lanka"; "Bangladesh"; "India"; "Japan"; "Philippines"; "Indonesia"}, 0)

and returns 1. The lookup value is found at the first position in the array.

#### Step 3 - Get value

The INDEX function returns a value from a cell range, you specify which value based on a row and column number.

INDEX(*array, [row_num], [column_num]*)

INDEX($G$4:$G$12, MATCH(B3, $F$4:$F$12,0))

becomes

INDEX($G$4:$G$12, 1)

and returns 27.

#### Step 4 - Add values

The plus sign lets you add numbers in an Excel formula.

C3+INDEX($G$4:$G$12, MATCH(B3, $F$4:$F$12,0))

becomes

99 + 27 equals 126.

## Get Excel *.xlsx file

Use IF + COUNTIF to perform multiple conditionsv2

### Logic category

This article demonstrates several ways to check if a cell contains any value based on a list. The first example […]

This article demonstrates formulas that perform a partial match for a given cell using multiple strings specified in cells F2 […]

The AND function allows you to have multiple conditions in an IF function, you can have up to 254 arguments. […]

### Excel categories

### 3 Responses to “Use IF + COUNTIF to evaluate multiple conditions”

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form

1. If item Count in Column-A have equal Count of the same item in corresponding Column-B, Result should be "Complete"

2. If item Count in Column-A have Count at least one in corresponding Column-B but less than Count in Column-A, Result should be "In progress"

3. If item Count in Column-A have no Count in corresponding Column-B, Result should be "Not Complete"

4. If there is no Count in Column-A and corresponding Column-B have no count, Result should be "Blank"

Please reply

If the marks of a student is less than 16 or his average is less than 50 he must be in D group.

How can i write this formula? Please write it for me

Please reply

If the marks of a student is less than 16 or his average is less than 50 he must be in D group.

How can i write this formula in table of contant? Please write it for me