Use a Cell Reference as an IF Logical Test in Excel
Question details
Understand how a cell reference works as the logical test in an Excel IF formula.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A formula uses G40 directly as the IF test before dividing by its value.
- Observed behavior
- For a numeric value in G40, zero is treated as FALSE and any nonzero value is treated as TRUE.
Check that G40 contains a numeric value and identify the cell where you want to enter the formula. The zero test prevents division by zero, but it does not handle every possible error or nonnumeric value.
Use an explicit zero comparison in the Excel IF formula
Make the logical test easier to read while returning zero when G40 is zero.
When G40 contains a number, =IF(G40,G31*1000*0.7/G40,0) treats zero as FALSE and any nonzero number, including a negative number, as TRUE. The explicit comparison G40<>0 expresses the same numeric test more clearly.
In your Excel worksheet, click the cell where you want the calculation to appear.
In the formula bar, enter =IF(G40<>0,G31*1000*0.7/G40,0) and press Enter.
Enter 0 in G40 to confirm the formula returns 0. Then enter a nonzero number in G40 to calculate G31*1000*0.7/G40.

Use an IF zero check in WPS Spreadsheets
In WPS Spreadsheets, enter an IF formula with an explicit comparison to calculate only when the denominator is nonzero.
- 1. Open the workbook: In WPS Spreadsheets, select Open and choose your workbook.
- 2. Check the referenced cells: Click G31 and G40 and confirm they contain the numeric values for your calculation.
- 3. Enter the formula: Select the result cell, enter =IF(G40<>0,G31*1000*0.7/G40,0) in the formula bar, and press Enter.
- 4. Test the zero case: Enter 0 in G40 and confirm that the result cell displays 0 rather than a division-by-zero error.

Frequently Asked Questions
What does =IF(G40,G31*1000*0.7/G40,0) mean?
When G40 contains a number, Excel treats a nonzero value as TRUE and calculates G31*1000*0.7/G40. If G40 is zero, the formula returns 0.
Why use G40<>0 instead of G40 in the IF test?
G40<>0 states the condition explicitly, making the formula easier to understand. For numeric values in G40, it tests the same zero-versus-nonzero condition.
Does a negative value in G40 count as TRUE?
Yes. A negative number is nonzero, so the IF formula uses the calculation branch.
Will the zero check handle text or errors in G40?
Not necessarily. The formula is intended for numeric values; check G40 for text or errors and add appropriate validation or error handling if those values are possible.




