IF practice exercises
Make a formula choose between two answers with IF: pass or fail, bonus or none, and nested IFs for more than two outcomes.
How IF works
IF makes a formula choose between two answers. It takes three arguments: a test that is either true or false, what to show when it is true, and what to show when it is false.
=IF(B2>=50,"Pass","Fail") shows Pass when the score in B2 is 50 or more and Fail otherwise. Text answers go in quotes; numbers and formulas don't, so =IF(C2>1000,C2*0.05,0) works out a 5% bonus only on sales over 1,000.
For more than two outcomes you can put one IF inside another, but past two or three levels IFS or a lookup table is easier to read. To test two conditions at once, put AND or OR inside the test. The exercises below cover pass or fail, a calculated bonus, comparing two cells, checking for text or an empty cell, and a nested IF.
- 1Pass or fail with IFThe passing score is 50. In C2, use IF to show "Pass" when the score in B2 is 50 or more, and "Fail" otherwise.
- 2Calculate a bonus with IFPremiumSellers with sales over 1000 get a 10% bonus; everyone else gets 0. In C2, use IF to calculate the bonus for B2.
- 3Three outcomes with nested IFPremiumGrade the score in B2: 90 or more is "A", 70 or more is "B", anything lower is "C". In C2, put a second IF inside the first.
- 4Flag missing values with ISBLANKPremiumIn D2, show "Missing" when the hours in B2 are blank, and otherwise the pay, B2*C2. Use IF with ISBLANK.
- 5Compare two cells with IFPremiumIn D2, show "Over budget" if the amount spent in C2 is more than the budget in B2, and "OK" if not.
- 6IF a cell contains a wordPremiumIn B2, show "Pro" if the product name in A2 contains "pro" anywhere, and "Standard" if it does not. IF has no wildcards, so test with ISNUMBER(SEARCH("pro",A2)).
Functions in this topic
Read the guide
- Excel test for a job interview: what it looks like and how to practice
- Free Excel course online: learn Excel from your first formula to job-ready
- Excel IF formulas: from one condition to many
- Best Excel courses online in 2026: 10 places to learn Excel, ranked
- Udemy vs Coursera vs LinkedIn Learning for Excel: which to pick
Questions
How do I use IF with multiple conditions?
Put AND or OR inside the test. =IF(AND(B2>=50,C2="Yes"),"Pass","Fail") needs both conditions, and =IF(OR(B2>=50,C2="Yes"),"Pass","Fail") needs only one. For several different outcomes, IFS is easier to read than nested IFs, but it needs Excel 2019 or Microsoft 365.
Why does my IF formula return FALSE or 0?
If you leave out the last argument, IF shows FALSE when the test fails: =IF(B2>=50,"Pass") gives FALSE for a 40. If you type the comma but nothing after it, you get 0. Add "" as the last argument, =IF(B2>=50,"Pass",""), to show an empty cell instead.
How do I color a cell with IF?
IF can only change the value, not the color. Use conditional formatting instead: select the cells, choose Conditional Formatting, New Rule, Use a formula, and enter the test, such as =B2>=50. Pick a fill color, and every cell that passes the test gets it.