# IF formula generator

> Describe what you need and get a IF formula for Excel and Google Sheets, run on real data before you copy it. Plus 8 tested IF examples.

Source: https://spreadsheetpractice.com/tools/formula-generator/if · Updated October 29, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

IF checks a condition and returns one value when it is true and another when it is false.

Describe the task at [IF formula generator](https://spreadsheetpractice.com/tools/formula-generator/if) and get a IF formula for Excel and Google Sheets, tested on real data.

## Tested IF examples

### Convert TRUE and FALSE to 1 and 0

`=--B2`

Excel. Result on the sample sheet: 7 rows (C2:C8). [See it and try it](https://spreadsheetpractice.com/formulas/convert-true-false-to-1-and-0)

### Calculate month-over-month growth

`=B3/B2-1`

Excel. Result on the sample sheet: 6 rows (C3:C8). [See it and try it](https://spreadsheetpractice.com/formulas/month-over-month-growth)

### Replace blank cells with 0 using a formula

`=IF(C2="",0,C2)`

Excel. Result on the sample sheet: 5 rows (E2:E6). [See it and try it](https://spreadsheetpractice.com/formulas/replace-blank-cells-with-zero)

### Return the category from a merged cell above

`=IF(A2="",C1,A2)`

Excel. Result on the sample sheet: 9 rows (C2:C10). [See it and try it](https://spreadsheetpractice.com/formulas/category-from-merged-cell-above)

### Fill blank cells with the value above using a formula

`=IF(A2="",D1,A2)`

Excel. Result on the sample sheet: 7 rows (D2:D8). [See it and try it](https://spreadsheetpractice.com/formulas/fill-blank-cells-with-value-above)

### Calculate shipping cost with an IF formula

`=IF(B2>=$F$1,0,$F$2)`

Excel. Result on the sample sheet: 5 rows (C2:C6). [See it and try it](https://spreadsheetpractice.com/formulas/shipping-cost-with-if)

### Use a checkbox in an IF formula

`=IF(C2,"Done","Open")`

Excel. Result on the sample sheet: 6 rows (D2:D7). [See it and try it](https://spreadsheetpractice.com/formulas/if-checkbox-is-checked)

### Why does my IF formula return FALSE

`=IF(B2>=$F$1,"Bonus","")`

Excel. Result on the sample sheet: 5 rows (C2:C6). [See it and try it](https://spreadsheetpractice.com/formulas/if-formula-returns-false)

## Questions

### What does the IF formula generator do?

You describe the task in plain English, and it writes the formula, using IF where that's the right tool, for your table or a sample one. The formula is run in our engine in Excel and Google Sheets mode before you see it, so you get its result, not just a guess.

### What does IF do?

IF checks a condition and returns one value when it is true and another when it is false.

### Can I learn to write IF formulas myself?

Yes. Each example below opens a page where you try the formula in a live grid and it's checked as you go, and the IF function page has a practice exercise.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
