4a. Using The If Function
4a. Using The If Function
Our spreadsheet
Once you've downloaded our spreadsheet, open the file in Excel or another
spreadsheet application. As you can see, our coworker Jordan has already added a ton
of information—there are several different columns, and each row contains the contact
information for one person, along with the amount of money that person donated.
While you might never have used it before, the IF function can simplify these kinds of
problems. The IF function can look at a value in a cell to see if it meets a basic condition
(in our example, if the value is greater than or equal to 50). Then it can then add text
to an empty cell. Here, we can use the IF function to look at each person's donation,
then add the words Free Gi if they donated at least $50. Basically, the IF function can
do the same thing we were planning to do, only it can do it much faster.
=IF(
Now, we'll add our arguments. The arguments will tell the IF function what to look for
and what to write in the cell depending on the outcome.
The first argument sets up the condition we want to test. For this formula, we want to
know if the value in cell G2 is greater than or equal to 50. We'll use some
mathematical operators ( > for greater than and = for equals ) to write the condition:
=IF(G2>=50
The next argument will tell the function what to write if the condition is true (that is, if
the value is greater than or equal to 50). This means the person will be getting a free gi ,
so we'll have it write Free Gi . Because this argument is text, we'll need to put it in
double quotes (" "). And, as with any function, we'll need to use a comma to separate
each argument:
The final argument will tell the function what to write if the condition is false. This
means the person won't get a free gi . We could make the function write something like
None or No, but in this case we actually just want the cell to remain blank. To do this,
we'll just type double quotes ("") with no text inside. This is also our last argument, so
go ahead and close the parentheses:
OK, you're done! When you press Enter, the words Free Gi should appear in the cell.
Now we can just drag the fill handle down to add the formula to the other cells in
column H:
Bonus Section
Try this!
Let's say our company is based in North Carolina and we want to know
which of our donors are local. Which of the following IF functions would
place the word Yes in the Local? column for donors from North Carolina
and No for those who live out of state?