# How to return 0 if a number is negative in Excel

Take the larger of 0 and the result: =MAX(0,B2-C2). Negative results become 0 and positive ones pass through.

**Excel:** `=MAX(0,B2-C2)` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D |
| --- | --- | --- | --- |
| Project | Budget | Spent | Remaining |
| Website | 12000 | 9850 |  |
| Rebrand | 8000 | 8640 |  |
| Video | 15000 | 15000 |  |
| Ads | 6500 | 2310 |  |
| Events | 9000 | 9725 |  |

Formula in D2, filled to D6: `=MAX(0,B2-C2)`

Result: $2,150; $0; $0; $4,190; $0

## How it works

MAX returns the larger of its arguments. When the subtraction is negative, 0 is larger, so you get 0; otherwise the remaining amount wins. It is the shortest way to write "if negative, then zero" and needs the subtraction only once.

## Other ways

- `=IF(B2-C2<0,0,B2-C2)`: The IF version spells the rule out, at the cost of writing the subtraction twice.
- `=IF(C2>B2,"Over budget",B2-C2)`: Flags overspending instead of hiding it. (Rebrand and Events show "Over budget".)

## Common mistakes

- MIN(0,…) does the opposite: it keeps the negative numbers and turns the positive ones into 0.
- A number format that hides negatives only changes the display; totals still include them.

## Questions

**How do I keep a result between 0 and a maximum?**

Nest MIN around MAX: `=MIN(1000,MAX(0,B2-C2))` keeps it between 0 and 1,000.

**How do I total only the positive differences?**

`=SUMPRODUCT((B2:B6>C2:C6)*(B2:B6-C2:C6))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/return-zero-if-negative
