1. Excel IF Function

      Excel IF function
      Summary 

      The IF function can perform a logical test and return one value for a TRUE result, and another for a FALSE result. For example, to "pass" scores above 70: =IF(A1>70,"Pass","Fail"). More than one condition can be tested by nesting IF functions. The IF function can be combined with logical functions like AND and OR.

      Purpose 
      Test for a specific condition
      Return value 
      The values you supply for TRUE or FALSE
      Syntax 
      =IF (logical_test, [value_if_true], [value_if_false])
      Arguments 
      • logical_test - A value or logical expression that can be evaluated as TRUE or FALSE.
      • value_if_true - [optional] The value to return when logical_test evaluates to TRUE.
      • value_if_false - [optional] The value to return when logical_test evaluates to FALSE.
      Usage notes 

      Use the IF function to test for or evaluate certain conditions, and then react differently depending on whether the test was TRUE or FALSE.

      In the example shown, we want to assign either "Pass" or "Fail" based on a test score. A passing score is 70 or higher. The formula in D6, copied down, is:

      =IF(C6>=70,"Pass","Fail")

      Translation: If the value in C6 is greater than or equal to 70, return "Pass". Otherwise, return "Fail".

      The logical flow this formula can be reversed. The formula below returns the same result:

      =IF(C6<70,"Fail","Pass")

      Translation: If the value in C6 is less than 70, return "Fail". Otherwise, return "Pass".

      Both formulas above, when copied down, will return correct results.

      Note: If you are new to the idea of formula criteria, this article explains many examples.

      Nested IF statements

      The IF function can be "nested". A "nested IF" refers to a formula where at least one IF function is nested inside another in order to test for more conditions and return more possible results. Each IF statement needs to be carefully "nested" inside another so that the logic is correct.

      For example, the following formula can be used to assign an grade rather than a pass / fail result:

      =IF(C6<70,"F",IF(C6<75,"D",IF(C6<85,"C",IF(C6<95,"B","A"))))

      Up to 64 IF functions can be nested. However, in general, you should consider other functions, like VLOOKUP or HLOOKUP for more complex scenarios, because they can handle more conditions in much more streamlined fashion.

      Logical operators

      When you are constructing a test with IF, you can use any of the following logical operators:

      Comparison operatorMeaningExample
      =equal toA1=D1
      >greater thanA1>D1
      >=greater than or equal toA1>=D1
      <less thanA1
      <=less than or equal toA1<=D1
      <>not equal toA1<>D1

      IF with AND, OR

      The IF function can be combined with the AND function and the OR function. For example, to return "OK" when A1 is between 7 and 10, you can use use a formula like this:

      =IF(AND(A1>7,A1<10),"OK","")

      Translation: if A1 is greater than 7 and less than 10, return "OK". Otherwise, return nothing ("").

      To return B1+10 when A1 is "red" or "blue" you can use the OR function like this:

      =IF(OR(A1="red",A1="blue"),B1+10,B1)

      Translation: if A1 is red or blue, return B1+10, otherwise return B1.

      More information

      See below for more IF function examples.

      Notes

      • To count things conditionally, use the COUNTIF or the COUNTIFS functions.
      • To sum things conditionally, use the SUMIF or the SUMIFS functions.
      • If any of the arguments to IF are supplied as arrays, the IF function will evaluate every element of the array.

          1. http://www.ilxs21.cn | http://m.ilxs21.cn | http://wap.ilxs21.cn | http://3g.ilxs21.cn | http://4g.ilxs21.cn | http://5g.ilxs21.cn | http://mobile.ilxs21.cn | http://vip.ilxs21.cn | http://ios.ilxs21.cn | http://anzhuo.ilxs21.cn | http://5.ilxs21.cn | http://e95.ilxs21.cn | http://1792.ilxs21.cn | http://www.ilxs21.cn/3a43aa.html | http://www.ilxs21.cn/c10.html | http://www.ilxs21.cn/3095.html | 我初三这毛算多么有图