Function Problems

Use an Excel IF Formula to Return Zero or Another Cell Value

Aamir Naveed AkramAamir Naveed Akram Dec 2, 2026 869 views

Question details

Create an IF formula that returns zero when P13 is negative or zero and returns the value in M13 when P13 is positive.

Use an Excel IF Formula to Return Zero or Another Cell Value
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet needs to display either zero or the value from another cell based on the value in P13.
Observed behavior
The desired result is 0 when P13 is less than or equal to zero and the value of M13 when P13 is greater than zero.
Before you start

Make sure P13 contains the number to test and M13 contains the value to return. Choose a different cell for the formula to avoid a circular reference.

Solution 1Recommended

Enter an IF Formula That Tests P13

Use this formula to return 0 for a nonpositive value in P13 or the value in M13 for a positive value.

1
Select an output cell

In the worksheet, click the cell where you want the result to appear. Do not select P13 or M13.

2
Enter the formula

Type =IF(P13<=0,0,M13) in the selected cell or the formula bar, then press Enter.

3
Check the result

Enter a negative number or 0 in P13 to check that the result is 0. Enter a positive number in P13 to check that the result matches M13.

Enter an IF Formula That Tests P13
Formula separators: If Excel does not accept commas as argument separators, try =IF(P13<=0;0;M13) instead.
Work with spreadsheet formulas

Use the Same IF Formula in WPS Spreadsheet

Open your workbook in WPS Spreadsheet and enter the IF formula to return zero or the value from M13 based on P13.

  1. 1. Open the workbook: In WPS Office, open WPS Spreadsheet and select Open to choose your workbook.
  2. 2. Select an output cell: Click a cell other than P13 or M13 where you want to display the result.
  3. 3. Enter the IF formula: Type =IF(P13<=0,0,M13) in the cell or formula bar and press Enter.
  4. 4. Save your changes: Select File > Save to save the updated workbook.
Test P13 and return the value from M13 with an IF formulaOpen and edit Microsoft Excel XLSX and XLS filesWork with formulas in a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

What does the formula return when P13 is exactly zero?

It returns 0 because the condition P13<=0 includes zero.

What happens if M13 contains text?

When P13 is positive, the formula returns the value in M13, including text. When P13 is zero or negative, it returns 0.

Why does Excel reject the formula with commas?

Your regional settings may use semicolons as argument separators. Try entering =IF(P13<=0;0;M13) in the formula bar.

Can I use the formula for other rows?

Yes. Enter the formula in an output cell and drag its fill handle down. Excel adjusts the relative references, such as P13 and M13, for each row.