Excel Training: IF Function

The IF function allows you to return one value or another based on a condition.

In this example (lesson-6.xlsx), the IF function will have to test the person's age and display "Yes" or "No" based on this test:

excel age test if function

Insert the IF function into cell C2 from the "Formulas" tab:

excel insert if function

The function window then opens and indicates what information is needed for this function:

excel if function

You can notice that this function requires 3 arguments (which are the data to be provided to the function).

When your cursor is in the field of an argument, a description is displayed below to help you better understand what data you should provide.

Now add the logical test by clicking on cell B2 (or entering B2) followed by >=18 to get the logical test B2>=18 (which will check if the value of B2 is greater than or equal to 18):

excel if function logical test

Then enter "Yes" for the value if TRUE and "No" for the value if FALSE:

excel if function age condition
Text values must be placed between "" in formulas as is the case here with "Yes" and "No".

Then copy the formula:

excel if function copy

To obtain:

excel if function copied