Formula Errors

Correct a Nested IF Formula for Multiple Conditions in Excel 2013

Phi Hung VoPhi Hung Vo Nov 18, 2026 869 views

Question details

Correct a nested IF formula that evaluates several conditions in cells E2 and F2.

Correct a Nested IF Formula for Multiple Conditions in Excel 2013
Product
Microsoft Excel 2013
Device & OS
not provided
Scenario
The user needs one formula to handle blank cells, equal values, zeros, negative values, and positive values.
Observed behavior
The nested formula produces a syntax error instead of evaluating the conditions.
Before you start

Check that E2 and F2 contain numbers or are blank, and choose a separate cell for the result. If your Excel regional settings use semicolons as argument separators, replace the formula's commas with semicolons.

Solution 1Recommended

Correct the Nested IF Formula with Combined Comparisons

Use this formula to check blanks and equal values first, then handle zero and negative values before dividing.

The order of the tests matters: equal values return 0 before either nonpositive-value test is applied. If E2 is nonpositive and the values are unequal, the formula returns 1; otherwise, if F2 is nonpositive, it returns -1.

1
Select the result cell

In the Excel worksheet, click an empty cell such as G2.

2
Enter the corrected formula

In the formula bar, enter =IF(OR(E2="",F2=""),"",IF(E2-F2=0,0,IF(E2<=0,1,IF(F2<=0,-1,F2/E2)))) and press Enter.

3
Test the conditions

Enter test values in E2 and F2. For example, 0 and 0 should return 0; 0 and 2 should return 1; 2 and 0 should return -1; and 4 and 2 should return 0.5. Leave either cell blank to check that the result is blank.

Correct the Nested IF Formula with Combined Comparisons
Check the intended results: The formula returns 0 for any equal numeric values, including equal negative values. Adjust the order of the tests if your expected results differ.
Work with formulas in WPS Office

Use the Nested IF Formula in WPS Spreadsheets

Open your workbook in WPS Spreadsheets and enter the same nested IF formula to evaluate blanks, equal values, zeros, negatives, and positive values.

  1. 1. Open the workbook: In WPS Spreadsheets, select Open and choose your Excel workbook.
  2. 2. Select a result cell: Click an empty cell such as G2, next to the values in E2 and F2.
  3. 3. Enter the formula: In the formula bar, enter =IF(OR(E2="",F2=""),"",IF(E2-F2=0,0,IF(E2<=0,1,IF(F2<=0,-1,F2/E2)))) and press Enter.
  4. 4. Verify the results: Change the values in E2 and F2 to test blank, equal, zero, negative, and positive cases, then use File > Save to save the workbook.
Evaluate multiple conditions with IF and ORCompatible with Microsoft Excel XLS and XLSX filesEdit formulas in a familiar spreadsheet interfaceUse WPS Office for free
microsoft office alternative - wps office

Frequently Asked Questions

Why does the formula check for equal values first?

The equality test returns 0 whenever E2 and F2 have the same numeric value. Because it comes before the nonpositive tests, equal zeros and equal negative values also return 0.

What happens if E2 or F2 is blank?

The OR(E2="",F2="") test returns an empty string if either cell is blank, so the result cell appears blank.

Why do I still get a formula syntax error?

Check that all parentheses are included and that the formula begins with an equals sign. If your regional settings require semicolons, replace the commas between arguments with semicolons.

What does the formula return when both values are positive?

If the positive values are equal, it returns 0. Otherwise, it divides F2 by E2; for example, E2=4 and F2=2 returns 0.5.