To run a formula only when a cell is not zero, wrap it in the IF function: =IF(A1<>0, your_formula, ""). The <> symbol means "not equal to", so Excel checks A1, runs your formula when the value is anything other than 0, and returns a blank (or whatever you put in the third argument) when it is 0. The same idea works for blank cells by swapping in <>"", and you can combine both checks if you need to catch empties and zeros together.

What You'll Need

  • Excel on desktop (Windows or Mac), Excel for the web, or Google Sheets. The IF syntax is the same in all of them.
  • A source cell that may contain 0, a blank, or a real value, and a formula you want to run only on the real values.
  • Basic familiarity with cell references such as A1 and with typing formulas that start with an equals sign.

Step-by-Step

  1. Identify the check cell and the formula you want to protect. Suppose column A holds quantities and you want to divide a total in B1 by each quantity. The formula you want to run is B1/A1. Running it on a zero produces #DIV/0!, which is exactly the error this pattern prevents.
  2. Type the IF wrapper. Click the cell where the result should appear and type:
    =IF(A1<>0, B1/A1, "")
    Press Enter. The first argument is the test, the second is what to do when the test is true, and the third is what to do when it is false.
  3. Decide what the false branch should return. An empty string "" leaves the cell visually blank, which is usually cleanest for reports. A zero 0 is better when you plan to chart the column, because charts treat text as a gap and may draw an odd line. A dash such as "-" signals "not applicable" to a human reader but is text, not a number.
  4. Fill the formula down. Drag the fill handle at the bottom-right corner of the cell, or double-click it to fill to the end of the adjacent data. Because the references are relative, A1 and B1 shift to A2 and B2 and so on. If B1 must stay fixed, write B$1 or $B$1 before filling.
  5. Handle blanks as well as zeros if needed. A blank cell is not equal to 0 in Excel's comparison, so =IF(A1<>0, B1/A1, "") will still try to divide by a blank and return #DIV/0!. Use =IF(N(A1)<>0, B1/A1, "") to treat blanks as zero, or test both conditions explicitly with =IF(AND(A1<>0, A1<>""), B1/A1, "").
  6. Check the logic with test values. Enter 0 in A1 and confirm the cell is blank, then type 4 and confirm the division appears. Try a negative number: it is "not zero" and will run the formula, so make sure the calculation makes sense for negatives.
  7. Adapt the pattern to other uses. For a lookup that should only run when a key exists, use =IF(A1<>0, VLOOKUP(A1, D:E, 2, FALSE), ""). For a text label, =IF(A1<>0, "In stock", "Out of stock"). The wrapper never changes: test first, formula second, fallback third.
  8. Save and review formatting. Blank-string results are text, so if the column is formatted as currency or percentage the blank cells may look inconsistent. Apply number formatting to the whole range rather than individual cells to keep columns aligned.

Common Mistakes

Using the wrong comparison operator. =IF(A1>0, ...) excludes negatives and blanks in ways you may not intend. Use <>0 when you genuinely mean "anything but zero".

Forgetting quotes around text. "" is an empty string; writing nothing at all between commas returns 0 instead of a blank. Mixing up these two is the most common reason a "blank" column shows zeros everywhere.

Assuming a blank equals zero. It does not. A truly empty cell compares as zero in some arithmetic contexts but not in an equality test against 0, which is why division formulas still break on blank rows.

Comparing text to a number. If A1 holds "0" as text (left-aligned, often from imported data), the comparison A1<>0 may behave unexpectedly. Convert with VALUE(A1) or use A1*1 inside the test.

Hard-coding the false branch duplicating work. Writing =IF(A1<>0, B1/A1, 0) and then averaging the column includes those artificial zeros and drags the average down. Leave blank if the zero is only a placeholder.

Tips

If the formula you are protecting can itself fail for other reasons, wrap it in IFERROR: =IFERROR(IF(A1<>0, B1/A1, ""), ""). This keeps the sheet clean without hiding logic you wrote yourself.

Use named ranges instead of raw references for readability. Selecting A1:A100 and naming it Quantities lets you write =IF(A1<>0, B1/Quantities, "") style formulas that are easier to audit later. Modern Excel also supports the IFS function for multiple conditions, and LET to store a value once so you do not repeat it.

To find every zero in a sheet quickly, select the range and use Home > Find & Select > Go To Special > Constants, then untick all except Numbers and use conditional formatting to highlight cells equal to 0. This helps you confirm which rows the IF wrapper will actually skip.

Remember labels can differ slightly between Excel versions, on the web, and in Google Sheets, but the IF function and its arguments are consistent across all of them.

Troubleshooting

The cell shows 0 instead of blank. Check that the third argument really is "" with quotation marks and not an empty slot. Also check that the cell is not part of a formula that references it, because a blank string can be coerced to zero downstream.

You still get #DIV/0!. The denominator is blank or text, not zero. Switch to the N(A1) or AND version from Step 5.

Nothing updates when you change the source cell. Calculation may be set to Manual. Go to the Formulas tab and set Calculation Options to Automatic, or press F9 to force a recalculation.

The formula works in one row but copies wrong. Look for misplaced dollar signs in the references, or for a row where the comparison cell contains a space. A space is text and is not equal to 0, so the formula runs when you expected it to skip.

Frequently Asked Questions

Can I use "not equal to zero" without IF?

Yes, in Google Sheets with IF alternatives or arithmetic tricks such as dividing by a boolean, but IF is the clearest and most portable option.

How do I test for zero and blank in one formula?

Use =IF(AND(A1<>0, A1<>""), B1/A1, ""). This skips both zeros and empty cells.

Does the test work with numbers formatted as text?

Not reliably. Convert text numbers before comparing, or use VALUE(A1)<>0.

What does the false argument return if I leave it out?

Excel returns FALSE when the test fails and you omit the third argument. Always supply it to control the output.

Can I use this pattern for conditional formatting?

Yes. Use a rule with a formula such as =A1<>0 to style only the cells that contain real values.