Description
The Excel IF function tests a user-defined condition and returns one result if the condition is true, and another result if the condition is false.
The syntax of the function is :
IF( logical_test, value_if_true, value_if_false )
where the arguments are as follows:
Nesting the Excel If Function
The If function is frequently 'nested' in Excel. I.e. the value_if_true or the value_if_false argument is replaced with another call to the If function (see Example 3 below).
Excel 2003 allows up to 7 levels of nested If functions, but Excel 2007 and Excel 2010 allow up to 64 levels of nesting. For Example, the following formula (which has 8 levels of nesting), will result in an error in Excel 2003 but will work correctly in Excel 2007 or Excel 2010 :
If you do find yourself using multiple levels of nesting, you should probably consider other Excel functions that can be used to obtain the same result more succinctly. For example, the above function could be made much simpler by using the Excel Choose function.
Excel If Function Examples
If Function Example 1
The following example shows the Excel If function applied to two sets of numbers. In this example, the logical_test checks whether the corresponding value in column B is equal to 0, and the function returns :
If Function Example 2
The logical_test within the Excel If function can be any type of expression that returns a TRUE or FALSE result. The following example shows some more examples of the function, using different types of logical_test.
If Function Example 3
The following example shows nesting of the Excel If function. The outer function has the same logical_test as in Example 1 above. However, in the example, the value_if_true argument is a further If function. Therefore:
No comments:
Post a Comment