IF function
The IF function is one of the most popular functions in Excel, and it allows you to make logical comparisons between a value and what you expect.
So an IF statement can have two results. The first result is if your comparison is True, the second if your comparison is False.
For example, =IF(C2=”Yes”,1,2) says IF(C2 = Yes, then return a 1, otherwise return a 2).
Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it’s false.
IF(logical_test, value_if_true, [value_if_false])
For example:
-
=IF(A2>B2,»Over Budget»,»OK»)
-
=IF(A2=B2,B4-A4,»»)
Argument name |
Description |
---|---|
logical_test (required) |
The condition you want to test. |
value_if_true (required) |
The value that you want returned if the result of logical_test is TRUE. |
value_if_false (optional) |
The value that you want returned if the result of logical_test is FALSE. |
Simple IF examples
-
=IF(C2=”Yes”,1,2)
In the above example, cell D2 says: IF(C2 = Yes, then return a 1, otherwise return a 2)
-
=IF(C2=1,”Yes”,”No”)
In this example, the formula in cell D2 says: IF(C2 = 1, then return Yes, otherwise return No)As you see, the IF function can be used to evaluate both text and values. It can also be used to evaluate errors. You are not limited to only checking if one thing is equal to another and returning a single result, you can also use mathematical operators and perform additional calculations depending on your criteria. You can also nest multiple IF functions together in order to perform multiple comparisons.
-
=IF(C2>B2,”Over Budget”,”Within Budget”)
In the above example, the IF function in D2 is saying IF(C2 Is Greater Than B2, then return “Over Budget”, otherwise return “Within Budget”)
-
=IF(C2>B2,C2-B2,0)
In the above illustration, instead of returning a text result, we are going to return a mathematical calculation. So the formula in E2 is saying IF(Actual is Greater than Budgeted, then Subtract the Budgeted amount from the Actual amount, otherwise return nothing).
-
=IF(E7=”Yes”,F5*0.0825,0)
In this example, the formula in F7 is saying IF(E7 = “Yes”, then calculate the Total Amount in F5 * 8.25%, otherwise no Sales Tax is due so return 0)
Note: If you are going to use text in formulas, you need to wrap the text in quotes (e.g. “Text”). The only exception to that is using TRUE or FALSE, which Excel automatically understands.
Common problems
Problem |
What went wrong |
---|---|
0 (zero) in cell |
There was no argument for either value_if_true or value_if_False arguments. To see the right value returned, add argument text to the two arguments, or add TRUE or FALSE to the argument. |
#NAME? in cell |
This usually means that the formula is misspelled. |
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
See Also
IF function — nested formulas and avoiding pitfalls
IFS function
Using IF with AND, OR and NOT functions
COUNTIF function
How to avoid broken formulas
Overview of formulas in Excel
Need more help?
To perform complicated and powerful data analysis, you need to test various conditions at a single point in time. The data analysis might require logical tests also within these multiple conditions.
For this, you need to perform Excel if statement with multiple conditions or ranges that include various If functions in a single formula.
Those who use Excel daily are well versed with Excel If statement as it is one of the most-used formula. Here you can check various Excel If or statement, Nested If, AND function, Excel IF statements, and how to use them. We have also provided a VIDEO TUTORIAL for different If Statements.
There are various If statements available in Excel. You have to know which of the Excel If you will work at what condition. Here you can check multiple conditions where you can use Excel If statement.
1) Excel If Statement
If you want to test a condition to get two outcomes then you can use this Excel If statement.
=If(Marks>=40, “Pass”)
2) Nested If Statement
Let’s take an example that met the below-mentioned condition
- If the score is between 0 to 60, then Grade F
- If the score is between 61 to 70, then Grade D
- If the score is between 71 to 80, then Grade C
- If the score is between 81 to 90, then Grade B
- If the score is between 91 to 100, then Grade A
Then to test the condition the syntax of the formula becomes,
=If(B5<60, “F”,If(B5<71, “D”, If(B5<81,”C”,If(B5<91,”B”,”A”)
3) Excel If with Logical Test
There are 2 different types of conditions AND and OR. You can use the IF statement in excel between two values in both these conditions to perform the logical test.
AND Function: If you are performing the logical test based on AND function, then excel will give you TRUE as an outcome in every condition else it will return false.
OR Function: If you are using OR condition for the logical test, then excel will give you an outcome as TRUE if any of the situations match else it returns false.
For this, multiple testing is to be done using AND and OR function, you should gain expertise in using either or both of these with IF statement. Here we have used if the function with 3 conditions.
How to apply IF & AND function in Excel
- To perform this multiple if and statements in excel, we will take the data set for the student’s marks that contain fields such as English and Math’s Marks.
- The score of the English subject is stored in the D column whereas the Maths score is stored in column E.
- Let say a student passes the class if his or her score in English is greater than or equal to 20 and he or she scores more than 60 in Maths.
- To create a report in matters of seconds, if formula combined with AND can suffice.
- Type =IF( Excel will display the logical hint just below the cell F2. The parameters of this function are logical_test, value_if_true, value_if_false.
- The first parameter contains the condition to be matched. You can use multiple If and AND conditions combined in this logical test.
- In the second parameter, type the value that you want Excel to display if the condition is true. Similarly, in the third parameter type the value that will be displayed if your condition is false.
- Apply If & And formula, you will get =IF(AND(D2>=20,E2>=60),”Pass”,”Fail”).
- Add Pass/Fail column in the current table.
- After you have applied this formula, you will find the result in the column.
- Copy the formula from cell F2 and paste in all other cells from F3 to F13.
How to use If with Or function in Excel
To use If and Or statement excel, you need to apply a similar formula as you have applied for If & And with the only difference is that if any of the condition is true then it will show you True.
To apply the formula, you have to follow the above process. The formula is =IF((OR(D2>=20, E2>=60)), “Pass”, “Fail”). If the score is equal or greater than 20 for column D or the second score is equal or greater than 60 then the person is the pass.
How to Use If with And & Or function
If you want to test data based on several multiple conditions then you have to apply both And & Or functions at a single point in time. For example,
Situation 1: If column D>=20 and column E>=60
Situation 2: If column D>=15 and column E>=60
If any of the situations met, then the candidate is passed, else failed. The formula is
=IF(OR(AND(D2>=20, E2>=60), AND(D2>=20, E2>=60)), “Pass”, “Fail”).
4) Excel If Statement with other functions
Above we have learned how to use excel if statement multiple conditions range with And/Or functions. Now we will be going to learn Excel If Statement with other excel functions.
- Excel If with Sum, Average, Min, and Max functions
Let’s take an example where we want to calculate the performance of any student with Poor, Satisfactory, and Good.
If the data set has a predefined structure that will not allow any of the modifications. Then you can add values with this If formula:
=If((A2+B2)>=50, “Good”, If((A2+B2)=>30, “Satisfactory”, “Poor”))
Using the Sum function,
=If(Sum(A2:B2)>=120, “Good”, If(Sum(A2:B2)>=100, “Satisfactory”, “Poor”))
Using the Average function,
=If(Average(A2:B2)>=40, “Good”, If(Average(A2:B2)>=25, “Satisfactory”, “Poor”))
Using Max/Min,
If you want to find out the highest scores, using the Max function. You can also find the lowest scores using the Min function.
=If(C2=Max($C$2:$C$10), “Best result”, “ “)
You can also find the lowest scores using the Min function.
=If(C2=Min($C$2:$C$10), “Worst result”, “ “)
If we combine both these formulas together, then we get
=If(C2=Max($C$2:$C$10), “Best result”, If(C2=Min($C$2:$C$10), “Worst result”, “ “))
You can also call it as nested if functions with other excel functions. To get a result, you can use these if functions with various different functions that are used in excel.
So there are four different ways and types of excel if statements, that you can use according to the situation or condition. Start using it today.
So this is all about Excel If statement multiple conditions ranges, you can also check how to add bullets in excel in our next post.
I hope you found this tutorial useful
You may also like the following Excel tutorials:
- Multiple If Statements in Excel
- Excel Logical test
- How to Compare Two Columns in Excel (using VLOOKUP & IF)
- Using IF Function with Dates in Excel (Easy Examples)
What is IF Function in Excel?
IF function in Excel evaluates whether a given condition is met and returns a value depending on whether the result is “true” or “false”. It is a conditional function of Excel, which returns the result based on the fulfillment or non-fulfillment of the given criteria.
For example, the IF formula in Excel can be applied as follows:
“=IF(condition A,“value B”,“value C”)”
The IF excel function returns “value B” if condition A is met and returns “value C” if condition A is not met.
It is often used to make logical interpretations which help in decision-making.
Table of contents
- What is IF Function in Excel?
- Syntax of the IF Excel Function
- How to Use IF Function in Excel?
- Example #1
- Example #2
- Example #3
- Example #4
- Example #5
- Guidelines for the Multiple IF Statements
- Frequently Asked Question
- IF Excel Function Video
- Recommended Articles
Syntax of the IF Excel Function
The syntax of the IF function is shown in the following image:
The IF excel function accepts the following arguments:
- Logical_test: It refers to the condition to be evaluated. The condition can be a value or a logical expression.
- Value_if_true: It is the value returned as a result when the condition is “true”.
- Value_if_false: It is the value returned as a result when the condition is “false”.
In the formula, the “logical_test” is a required argument, whereas the “value_if_true” and “value_if_false” are optional arguments.
The IF formula uses logical operators to evaluate the values in a range of cells. The following table shows the different logical operatorsLogical operators in excel are also known as the comparison operators and they are used to compare two or more values, the return output given by these operators are either true or false, we get true value when the conditions match the criteria and false as a result when the conditions do not match the criteria.read more and their meaning.
Operator | Meaning |
---|---|
= | Equal to |
> | Greater than |
>= | Greater than or equal to |
< | Less than |
<= | Less than or equal to |
<> | Not equal to |
How to Use IF Function in Excel?
Let us understand the working of the IF function with the help of the following examples in Excel.
You can download this IF Function Excel Template here – IF Function Excel Template
Example #1
If there is no oxygen on a planet, life is impossible. If oxygen is available on a planet, then life is possible. The following table shows a list of planets in column A and the information on the availability of oxygen in column B. We have to find the planets where life is possible, based on the condition of oxygen availability.
Let us apply the IF formula to cell C2 to find out whether life is possible on the planets listed in the table.
The IF formula is stated as follows:
“=IF(B2=“Yes”, “Life is Possible”, “Life is Not Possible”)
The succeeding image shows the IF formula applied to cell C2.
The subsequent image shows how the IF formula is applied to the range of cells C2:C5.
Drag the cells to view the output of all the planets.
The output in the below worksheet shows life is possible on the planet Earth.
Flow Chart of Generic IF Excel Function
The IF Function Flow Chart for Mars (Example #1)
The flow of IF function flowchart for Jupiter and Venus is the same as the IF function flowchart for Mars (Example #1).
The IF Function Flow Chart for Earth
Hence, the IF excel function allows making logical comparisons between values. The modus operandi of the IF function is stated as: If something is true, then do something; otherwise, do something else.
Example #2
The following table shows a list of years. We want to find out if the given year is a leap year or not.
A leap year has 366 days; the extra day is the 29th of February. The criteria for a leap year are stated as follows:
- The year will be exactly divisible by 4 and not exactly be divisible by 100 or
- The year will be exactly divisible by 400.
In this example, we will use the IF function along with the AND, OR, and MOD functions to find the leap years.
We use the MOD function to find a remainder after a dividend is divided by a divisor.
The AND functionThe AND function in Excel is classified as a logical function; it returns TRUE if the specified conditions are met, otherwise it returns FALSE.read more evaluates both the conditions of the leap years for the value “true”. The OR functionThe OR function in Excel is used to test various conditions, allowing you to compare two values or statements in Excel. If at least one of the arguments or conditions evaluates to TRUE, it will return TRUE. Similarly, if all of the arguments or conditions are FALSE, it will return FASLE.read more evaluates either of the condition for the value “true”.
We will apply the MOD function to the conditions as follows:
If MOD(year,4)=0 and MOD(year,100)<>(is not equal to) 0, then the year is a leap year.
or
If MOD(year,400)=0, then the year is a leap year; otherwise, the year is not a leap year.
The IF formula is stated as follows:
“=IF(OR(AND((MOD(year,4)=0),(MOD(year,100)<>0)),(MOD(year,400)=0)),“Leap Year”, “Not A Leap Year”)”
The argument “year” refers to a reference value.
The following images show the output of the IF formula applied in the range of cells.
The following image shows how the IF formula is applied to the range of cells B2:B18.
The succeeding table shows the years 1960, 2028, and 2148 as leap years and the remaining as non-leap years.
The result of the IF excel formula is displayed for the range of cells B2:B18 in the following image.
Example #3
The succeeding table shows a list of drivers and the directions they undertook to reach the destination. It is preceded by an image of the road intersection explaining the turns taken by the drivers and their destinations. The right turn leads to town B, and the left turn leads to town C. Identify the driver’s destination to town B and town C.
Road Intersection Image
Let us apply the IF excel function to find the destination. Here, the condition is mentioned as follows:
- If the driver turns right, he/she reaches town B.
- If the driver turns left, he/she reaches town C.
We use the following IF formula to find the destination:
“=IF(B2=“Left”, “Town C”, “Town B”)”
The succeeding image shows the output of the IF formula applied to cell C2.
Drag the cells to use the formula in the range C2:C11. Finally, we get the destinations of each driver for their turning movements.
The below image displays the IF formula applied to the range.
The output of the IF formula and the destinations are displayed in the succeeding image.
The result shows that six drivers reached town C, and the remaining four have reached town B.
Example #4
The following table shows a list of items and their inventory levels. We want to check if the specific item is available in the inventory or not using the IF function.
Let us list the name of items in column A and the number of items in column B. The list of data to be validated for the entire items list is shown in the cell E2 of the below image.
We use the Excel IF along with the VLOOKUP functionThe VLOOKUP excel function searches for a particular value and returns a corresponding match based on a unique identifier. A unique identifier is uniquely associated with all the records of the database. For instance, employee ID, student roll number, customer contact number, seller email address, etc., are unique identifiers.
read more to check the availability of the items in the inventory.
The VLOOKUP function looks up the values referring to the number of items, and the IF function will check whether the item number is greater than zero or not.
We will apply the following IF formula in the F2 cell:
“=IF(VLOOKUP(E2,A2:B11,2,0)=0, “Item Not Available”,“Item Available”)”
If the lookup value of an item is equal to 0, then the item is not available; else, the item is available.
The succeeding image shows the result of the IF formula in the cell F2.
Select “bat” in the E2 item cell to know whether the item is available or not in the inventory (as shown in the following image).
Example #5
The following table shows the list of students and their marks. The grade criteria are provided based on the marks obtained by the students. We want to find the grade of each student in the list.
We apply the Nested IF in Excel since we have multiple criteria to find and decide each student’s grade.
The Nesting of IF function uses the IF function inside another IF formula when multiple conditions are to be fulfilled.
The syntax of Nesting of IF function is stated as follows:
“=IF( condition1, value_if_true1, IF( condition2, value_if_true2, value_if_false2 ))”
The succeeding table represents the range of scores and the grades, respectively.
Let us apply the multiple IF conditions with AND function in the below-nested formula to find out the grade of the students:
“=IF((B2>=95),“A”,IF(AND(B2>=85,B2<=94),“B”,IF(AND(B2>=75,B2<=84),“C”,IF(AND(B2>=61,B2<=74),“D”,“F”))))”
The IF function checks the logical condition as shown in the formula below:
“=IF(logical_test, [value_if_true],[value_if_false])”
We will split the above-mentioned nested formula and check the IF statements as shown below:
First Logical Test: B2>=95
If the formula returns,
- Value_if_true, execute: “A” (Grade A) else(comma) enter value_if_false
- Value_if_false, then the formula finds another IF condition and enter IF condition
Second Logical Test: B2>=85(logical expression 1) and B2<=94(logical expression 2)
(We use AND function to check the multiple logical expressions as the two given conditions are to be evaluated for “true.”)
If the formula returns,
- Value_if_true, execute: “B” (Grade B) else(comma) enter value_if_false
- Value_if_false, then the formula finds another IF condition and enter IF condition
Third Logical Test: B2>=75(logical expression 1) and B2<=84(logical expression 2)
(We use AND function to check the multiple logical expressions as the two given conditions are to be evaluated for “true.”)
If the formula returns,
- Value_if_true, execute: “C” (Grade C) else(comma) enter value_if_false
- value_if_false, then the formula finds another IF condition and enter IF condition
Fourth Logical Test: B2>=61(logical expression 1) and B2<=74(logical expression 2)
(We use AND function to check the multiple logical expressions as the two given conditions are to be evaluated for “true.”)
If the formula returns,
- Value_if_true, execute: “D” (Grade D) else(comma) enter value_if_false
- Value_if_false, execute: “F” (Grade F)
- Finally, close the parenthesis.
The below image displays the output of the IF formula applied to the range.
The succeeding image shows the IF nested formula applied to the range.
The grades of the students are listed in the following table.
Guidelines for the Multiple IF Statements
The guidelines for the multiple IF statements are listed as follows:
- Use nested IF function to a limited extent as multiple IF statements require a great deal of thought to be accurate.
- Multiple IF statementsIn Excel, multiple IF conditions are IF statements that are contained within another IF statement. They are used to test multiple conditions at the same time and return distinct values. Additional IF statements can be included in the ‘value if true’ and ‘value if false’ arguments of a standard IF formula.read more require multiple parentheses (), which is often difficult to manage. Excel provides a way to check the color of each opening and closing parenthesis to avoid this situation. The last closing parenthesis color will always be black, denoting the end of the formula statement.
- Whenever we pass a string value for the arguments “value_if_true” and “value_if_false” or test a reference against a string value, enclose the string value in double quotes. Passing a string value without quotes will result in “#NAME?” error.
Frequently Asked Question
1. What is the IF function in Excel?
The Excel IF function is a logical function that checks the given criteria and returns one value for a “true” and another value for a “false” result.
The syntax of the IF function is stated as follows:
“=IF(logical_test, [value_if_true], [value_if_false])”
The arguments are as follows:
1. Logical_test – It refers to a value or condition that is tested.
2. Value_if_true – It is the value returned when the condition logical_test is “true.”
3. Value_if_false – It is the value returned when the condition logical_test is “false.”
The “logical_test” is a required argument, whereas the “value_if_true” and “value_if_false” are optional arguments.
2. How to use the IF Excel function with multiple conditions?
The IF Excel statement for multiple conditions is created by using multiple IF functions in a single formula.
The syntax of IF function with multiple conditions is stated as follows:
“=IF (condition 1_“true”, do something, IF (condition 2_“true”, do something, IF (condition 3_ “true”, do something, else do something)))”
3. How to use the function IFERROR in Excel?
IF Excel Function Video
Recommended Articles
This has been a guide to the IF function in Excel. Here we discuss how to use the IF function along with examples and downloadable templates. You may also look at these useful functions –
- What is the Logical Test in Excel?A logical test in Excel results in an analytical output, either true or false. The equals to operator, “=,” is the most commonly used logical test.read more
- “Not Equal to” in Excel“Not Equal to” argument in excel is inserted with the expression <>. The two brackets posing away from each other command excel of the “Not Equal to” argument, and the user then makes excel checks if two values are not equal to each other.read more
- Data Validation ExcelThe data validation in excel helps control the kind of input entered by a user in the worksheet.read more
Many people usually asked that how to write an excel nested if statements based on multiple ranges of cells to return different values in a cell? How to nested if statement using date ranges? How to use nested if statement between different values in excel 2013 or 2016?
- Nested IF statements based on multiple ranges
- Nested IF Statement Using Date Ranges
- Nested IF Statements For A Range Of Cells
- Nested IF Statement between different values
This post will guide you how to understand excel nested if statements through some classic examples.
Table of Contents
- Nested IF statements based on multiple ranges
- Nested IF Statement Using Date Ranges
- Nested IF Statements For A Range Of Cells
- Nested IF Statement between different values
- Related Functions
Nested IF statements based on multiple ranges
Assuming that you want to reflect the below request through nested if statements:
a) If 1<B1<0, Then return 0.1
b) If 0.99<B1<5, then return 0.15
c) If 4.99<B1<15, then return 0.2
d) If 14.99<B1<30, then return 0.5
So if B1 cell was “14.5”, then the formula should be returned “0.2” in the cell.
From above logic request, we can get that it need 4 if statements in the excel formula, and there are multiple ranges so that we can combine with logical function AND in the nested if statements. The below is the nested if statements that I have tested.
=IF(AND(B1>0,B1<1),0.1,IF(AND(B1>0.99, B1<5),0.15, IF(AND(B1>4.99,B1<15),0.2, IF(AND(B1>14.99,B1<30),0.5,””))))
If you don’t want to use AND function in the above nested if statement, can try the below formula:
=IF(B1<1,0.1, If(B1<5,0.15,IF(B1<15,0.2,IF(B1<30,0.5,””))))
Nested IF Statement Using Date Ranges
I want to write a nested IF statement to calculated the right Quarter based one the criteria in the below table.
According to the request, we need to compare date ranges, such as: if B1<E2<C1, then return A1.
So we can consider to use AND logical function in the nested if statement. The formula is as follows:
=IF(AND(E2>B1,E2<C1),A1,IF(AND(E2>B2,E2<C2),A2,IF(AND(E2>B3,E2<C3),A3,IF(AND(E2>B4,E2<C3),A4))))
Or we can use INDEX function and combine with MATCH Function to get the right quarter.
=INDEX($A$1:$A$4,MATCH(E2,$B$1:$B$4,1))
Nested IF Statements For A Range Of Cells
If you have the following requirement and need to write a nested IF statement in excel:
If any of the cells A1 to C1 contain “excelhow”, then return “excelhow” in the cell E1.
If any of the cells A1 to C1 contain “google”, then return “excelhow” in the cell E1.
If any of the cells A1 to C1 contain “ibm”, then return “ibm” in the cell E1.
If any of the cells A1 to C1 contain “Cloud”, then return “ibm” in the cell E1.
How to check if cell ranges A1:C1 contain another string, using “COUNTIF” function is a good choice.
Countif function: Counts the number of cells within a range that meet the given criteria
Let’s try to test the below nested if statement:
=IF(OR(COUNTIF(A3:C3,"excelhow")>0,COUNTIF(A3:C3,"google")>0),"excelhow",IF(OR(COUNTIF(A3:C3,"ibm")>0,COUNTIF(A3:D3,"cloud")>0),"ibm",""))
Nested IF Statement between different values
Assuming you have the following different range values, if the B1 has the value 65, then expected to return “under average”in cell C1, if the Cell B1 has the value 75, then return “average” in cell C1. And if the Cell B1 has the value 85, then return “above average” in the cell C1.
0-70 | under average |
71-80 | average |
81-100 | above average |
How do I format the nested if statement in Cell C1 to display the right value? Just try to use the below nested if function or using INDEX function.
=IF(B1< 0,"",IF(B1<= 70, "under average",IF(B1<=80, "Average", IF(B1<=100,"Above Average",""))))
- Excel IF function
The Excel IF function perform a logical test to return one value if the condition is TRUE and return another value if the condition is FALSE. The IF function is a build-in function in Microsoft Excel and it is categorized as a Logical Function.The syntax of the IF function is as below:= IF (condition, [true_value], [false_value])…. - Excel nested if function
The nested IF function is formed by multiple if statements within one Excel if function. This excel nested if statement makes it possible for a single formula to take multiple actions… - Excel AND function
The Excel AND function returns TRUE if all of arguments are TRUE, and it returns FALSE if any of arguments are FALSE.The syntax of the AND function is as below:= AND (condition1,[condition2],…) … - Excel COUNTIF function
The Excel COUNTIF function will count the number of cells in a range that meet a given criteria.This function can be used to count the different kinds of cells with number, date, text values, blank, non-blanks, or containing specific characters.etc.The syntax of the COUNTIF function is as below:= COUNTIF (range, criteria) … - Excel INDEX function
The Excel INDEX function returns a value from a table based on the index (row number and column number)The INDEX function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the INDEX function is as below:= INDEX (array, row_num,[column_num])… - Excel MATCH function
The Excel MATCH function search a value in an array and returns the position of that item.The MATCH function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the MATCH function is as below:= MATCH (lookup_value, lookup_array, [match_type])….
Is there a function that will create a range (from a range) if they match values? Essentially, I’m looking for something like COUNTIF
, that will return the cells that actually match my IF
.
Ideally, something like RANGEIF(<NORMAL_RANGE_HERE>, ">"&C12)
, which will return all cells in <NORMAL_RANGE_HERE>
that are greater than C12
.
asked Mar 11, 2011 at 16:48
Glen SolsberryGlen Solsberry
3731 gold badge8 silver badges20 bronze badges
2
The solution here is to use IF, but use it as an array function. For example, if you have this table (sorry for the formatting):
A B C D
______________
1 | 1 3 2 5
2 | 8 1 3 2
3 | 5 4 3 9
Now say you only wanted values that were greater than three in an identical table.
- Select an empty block of cells matching the size of your original table.
- Now type in the formula (remember to make sure you have your whole new cell block selected, very important): =IF(A1:D3>3,A1:D3,»»).
- Now don’t just hit Enter… In order to enter this as an array function you need to hit Ctrl-Shift-Enter.
- Now that one formula is applied to the entire cell block as an ‘array formula’ and it will evaluate the range you put into the IF formula cell by cell depending on the cell’s location in the array. You can tell it was applied as an array formula by clicking on one of the cells. In the formula editor you should see the formula enclosed in curly braces like this: {=IF(A1:D3>3A1:D3,»»)}
You should end up with (assuming your empty block was F1:I3):
F G H I
______________
1 | 5
2 | 8
3 | 5 4 9
Hopefully this is enough to get you going. Do a Google search for «excel array formula» for more info. Hope this helps!
answered Mar 28, 2011 at 20:05
1