IF function
IF function
If Function
An If function is used to make logical comparisons between values, returning a value of either True or
False. The if function will carry out a specific operation, based on a true or a false value.
Comparison Operators
• = - equal to
• > - greater than
• < - less than
• >= - greater than or equal to
• <= - less than or equal to
• <> - not equal to
It is best to put the values being used in an IF function into their own individual cell, and then reference
that cell within the IF function. If a value has to change, the value is changed in the referenced cell’s
location and all functions related to that function are now updated immediately.
Enter an IF function
IF functions may be entered by;
• Choosing the IF function from the Formulas tab, which will use the Insert Function option.
o This option is recommended when first using functions, as it is an easy to learn about
the arguments for a function.
• Typing directly into a cell
• Typing into the formula bar
Formulas tab
To enter an IF function, place the cursor in the cell that will contain the function and
then navigate to the Formulas tab. On the Formulas tab, functions are separated into
categories. Click on a Logical category dropdown and then select the IF option.
Another option to insert an IF function is to use the Insert function button from the
Formulas tab.
The insert function option allows users to search for a description of what they want to do instead of
having to know the name of a function. To insert an IF function, type if in the search textbox and then
hit the Go button to populate the results.
Select IF name from the Select a function box. On the bottom of the Insert Function, excel will display
the function and its arguments, along with a description of the function. To choose a function, double
click on the function name, or select the function and then click the OK button.
To enter the data for an argument, manually type in the data into the textbox, or select the
corresponding cell within the sheet.
When all required arguments are entered, click on the OK button to complete the function.
To view a description of any of the suggested functions, use the arrow keys on the keyboard to highlight
the function, or single click on the function name with the mouse. To select a function, use the arrow
keys to highlight the function and then hit the tab key, or double click on the function name.
Tip: The closed parenthesis is not required to be entered to complete a function. Simply hit the Enter
key and Excel will add the closed parenthesis to complete the function.
For example; Excel reads the formula in cell C1 as “add the number in
the cell located two columns to the left to the number in the cell
located one column to the left”. When the formula, which appears as
=A1+B1, is copied to the cell below, it performs the calculation using
the same pattern, but updates the formula to reflect the appropriate
cell addresses, =A2+B2.
To cycle through all Absolute reference options, press the F4 key while
the cell reference is highlighted.
1. The first time the F4 key is pressed, an absolute reference to an individual cell is made.
2. The second time F4 is pressed, the reference will be to the row only, meaning the row number is
held constant, but the column letter can update.
3. The third time F4 is pressed, the reference will be to the column only, meaning the column
letter is held constant, but the row number can update.
4. The fourth time F4 is pressed, the reference will return to a relative cell reference.
Tip: The F4 key may also be pressed immediately after clicking on a cell within a function, instead of
having to go back into the function to update it.
The And and Or functions will allow for multiple logical expressions to be created within the argument of
the function, instead of just a single option when using an IF function.
And Function
The And function will return a True value if every one of the logical expressions is true.
OR Function
The OR function will return a True value as long as one of the logical expressions is true.
The steps below will walk through the process of creating an AND function within an IF function. To have
an OR function in the IF function, follow the same steps, but enter OR instead of AND.
Navigate to the cell that will contain the IF function. We will start by
creating the AND function, so type in an equal sign, followed by AND.
Select the AND function by double clicking on it, or using the arrow keys to
select the function and then hit the tab key.
Navigate to the front of the AND of OR function and place the cursor after the equal sign
Tip: This may also be done in the formula bar, as it may be easier to access the first portion of the
function in the formula bar instead of in a cell.
Note: Users may hit the Enter key instead of typing in the closed parenthesis to complete the function,
which may populate an error.
This error is just notifying the user that the last closed bracket is missing. By accepting this error, Excel
will insert the closed bracket to complete the function.
The way a nested IF function works is a logical_test is tested, if that test returns a TRUE value,
something will happen, but if it returns a FALSE value, another IF function will be used to determine if
the logical_test fits into another qualifier.
If comparing values on a scale, make sure the values are sorted in either increasing or decreasing order.
If the scale is in Increasing order, the less than < sign will be used in the arguments and if the scale is in
decreasing order, the greater than > sign will be used in the arguments.
To select a function, use the arrow keys to highlight the function and then hit
the tab key, or double click on the function name.
Enter in the first logical test within the If function, then hit
the comma key to get to the value_if_true.
It is best to ignore the data of the first IF function and work solely on the second IF function by working
through the arguments.
Note: If more logical tests were being compared, another IF function may be entered into the
value_if_false portion of the second IF function, following the same steps that were taken above.
When the closed bracket is typed, users will notice that the IF function argument below the cell will now
display the value_if_false argument of the first IF function. Since the second IF function has completed
the value_if_false portion of the first IF function the nested if is now complete. To complete the nested
IF function, either type in another closed bracket ), or hit the Enter key.
The V in VLOOKUP stands for vertical, so the array (table) must be arranged vertically.
• Lookup_value – This is the value that is being searched for in the Table_Array.
• Table_array – A table with two or more columns.
• Col_index_num – The column number in the table_array which contains the value that is to be
returned as a result.
• Range_lookup(optional) – a logical value containing either True or False.
o TRUE(or blank) - an approximate match is returned (if an exact match is not found, the
next largest value within the Lookup_Value is returned)
o FALSE – an exact match must be found to return the value in the col_index_num
Create a Table_array
Before using the VLOOKUP function, a Table_array must be created that contains the searched for
values (lookup_value) in the leftmost column, as well a return value that will be populated when a value
is found.
Note: When the syntax for a VLOOKUP are learned, a VLOOKUP may be entered by
typing an equal (=) sign in a cell followed by the text vlookup. Highlight the vlookup
function and then hit tab to accept the function and provide the data for the first
argument. Use the comma keys to
navigate between the arguments, hitting
the enter key when all arguments have
been completed.
Place the cursor in the cell that is to hold the VLOOKUP function, which is also the cell that will display
the value that will be populated from the table_array.
Navigate to the Formula tab and then click on the Insert Formula icon.
The Insert Formula dialog will appear.
On the Insert Function dialog box, type “vlookup” in the search for a
function textbox and then click the Go button.
Highlight VLOOKUP from the select a function area and then click the OK button.
Every argument of the VLOOKUP function will be listed on the Function Argument window. To view a
description of each argument, place the cursor in that argument’s textbox.
• Lookup_value – This is the value that is being searched for in the Table_Array.
• Table_array – A table with two or more columns.
o The table_array must be absolute referenced.
This can be done by selecting the table_array and then hitting the F4 key once.
• Col_index_num – The column number in the table_array which contains the value that is to be
returned as a result.
• Range_lookup(optional) – a logical value containing either True or False.
o TRUE(or blank) - an approximate match is returned (if an exact match is not found, the
next largest value within the Lookup_Value is returned)
o FALSE – an exact match must be found to return the value in the col_index_num
To enter the arguments, position the cursor in the argument textbox and then navigate to the
corresponding worksheet containing the argument data and select the cell.
The col_index_num is the column number that contains the value that will populate in the cell that the
VLOOKUP is being entered in.
The Range_lookup is either left blank (TRUE) or FALSE is entered. FALSE means the value being searched
for must be an exact match to a value in the first column of the table _array.
This example is searching for score as a percent and displaying the corresponding letter grade. Since the
scores do not have to be exact, the Range_lookup is left blank.