Free demo · Microsoft Excel · Lesson 6 · Intermediate · Logical functions
The IF function: let Excel decide
IF asks a yes-or-no question about a cell, then shows one answer when it is true and another when it is false.
- 1In C2 type
=IF(B2>=20,"Yes","No"): the test, then the two answers - 2Press Enter: 24 ≥ 20 is TRUE, so Yes
- 3Fill down: each row tests its own number. 18 and 15 give No
- 4Text goes in quotes, numbers don't: in D2 type
=IF(B2>=20,2,1) - 5Enter, then fill down: 2, 2, 1, 1, numbers you can add up
- ✓Computers grows to 20: the answers flip to Yes and 2 (
>=includes 20)