19/10/2019
Use IF THEN Excel formula to automate certain Excel functions.
Sometimes, we don't want to count the number of times a value appears. Instead, we want to input different information into a cell if there is a corresponding cell with that information.
For example, in the situation below, I want to award ten points to everyone who belongs in the Gryffindor house. Instead of manually typing in 10's next to each Gryffindor student's name, I can use the IF THEN Excel formula to say that if the student is in Gryffindor, then they should get ten points.
The formula: IF(logical_test, value_if_true, value of false)
Example Shown Below: =IF(D2="Gryffindor","10","0")
In general terms, the formula would be IF(Logical Test, value of true, value of false). Let's dig into each of these variables.
Logical_Test: The logical test is the "IF" part of the statement. In this case, the logic is D2="Gryffindor" because we want to make sure that the cell corresponding with the student says "Gryffindor." Make sure to put Gryffindor in quotation marks here.
Value_if_True: This is what we want the cell to show if the value is true. In this case, we want the cell to show "10" to indicate that the student was awarded the 10 points. Only use quotation marks if you want the result to be text instead of a number.
Value_if_False: This is what we want the cell to show if the value is false. In this case, for any student not in Gryffindor, we want the cell to show "0" to show 0 points. Only use quotation marks if you want the result to be text instead of a number.
IF THEN formula in Excel
Note: In the example above, I awarded 10 points to everyone in Gryffindor. If I later wanted to sum the total number of points, I wouldn't be able to because the 10's are in quotes, thus making them text and not a number that Excel can sum.