# IF and logic formulas in Excel and Google Sheets

> Flags, pass and fail, grades, multiple conditions and hiding errors the right way. 6 answers, each checked by running it.

Source: https://spreadsheetpractice.com/formulas/topic/logic · Updated October 29, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on October 29, 2026

## Answers

- [How to check if a cell contains specific text in Excel](https://spreadsheetpractice.com/formulas/if-cell-contains-text): Combine SEARCH with ISNUMBER inside IF: =IF(ISNUMBER(SEARCH(text,cell)),"Yes","No"). `=IF(ISNUMBER(SEARCH($E$1,A2)),"Yes","No")`
- [How to use IF with multiple conditions in Excel](https://spreadsheetpractice.com/formulas/if-with-multiple-conditions): Put the conditions in AND (all must be true) or OR (any can be true) inside IF: =IF(AND(cond1,cond2),"yes","no"). `=IF(AND(B2>=$G$1,C2>=$G$2),"Bonus","No bonus")`
- [How to assign letter grades with IF or IFS in Excel](https://spreadsheetpractice.com/formulas/nested-if-grades): Use IFS with the conditions from the highest grade down: =IFS(score>=90,"A",score>=80,"B",score>=70,"C",score>=60,"D",TRUE,"F"). `=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",B2>=60,"D",TRUE,"F")`
- [How to check if a cell is blank in Excel](https://spreadsheetpractice.com/formulas/if-cell-is-blank): Test the cell against "": =IF(C2="","Not shipped",C2-B2). ISBLANK(C2) works too, but only for truly empty cells. `=IF(C2="","Not shipped",C2-B2)`
- [How to replace #DIV/0! with 0 or a blank in Excel](https://spreadsheetpractice.com/formulas/replace-div0-error-with-zero): Wrap the division in IFERROR: =IFERROR(B2/C2,0). For only the zero case, test the divisor: =IF(C2=0,0,B2/C2). `=IFERROR(B2/C2,0)`
- [How to check if a number is between two values in Excel](https://spreadsheetpractice.com/formulas/if-between-two-numbers): Use AND with both limits: =IF(AND(value>=low,value<=high),"In range","Out of range"). `=IF(AND(B2>=$F$1,B2<=$F$2),"In range","Out of range")`

More topics: [Counting formulas](https://spreadsheetpractice.com/formulas/topic/count) · [Sum formulas](https://spreadsheetpractice.com/formulas/topic/sum) · [Lookup formulas](https://spreadsheetpractice.com/formulas/topic/lookup) · [Text formulas](https://spreadsheetpractice.com/formulas/topic/text) · [Date formulas](https://spreadsheetpractice.com/formulas/topic/date) · [Dynamic array formulas](https://spreadsheetpractice.com/formulas/topic/dynamic) · [Duplicates and data cleanup formulas](https://spreadsheetpractice.com/formulas/topic/cleanup) · [Rounding and math formulas](https://spreadsheetpractice.com/formulas/topic/math) · [Percentage formulas](https://spreadsheetpractice.com/formulas/topic/percent)

Every answer: [Formula answers](https://spreadsheetpractice.com/formulas). Formulas used: `IF`, `ISNUMBER`, `SEARCH`, `AND`, `IFS`, `IFERROR`

---

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