# How to calculate profit margin percentage in Excel

Divide profit by revenue: =(B2-C2)/B2, where B is the price or revenue and C the cost.

**Excel:** `=(B2-C2)/B2` (Every current version)

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

## Example

Sample data (row 1 is the header):

| A | B | C | D |
| --- | --- | --- | --- |
| Product | Price | Cost | Margin |
| Lamp | 39.99 | 21.5 |  |
| Chair | 249 | 162 |  |
| Desk | 449 | 301 |  |
| Monitor | 189.5 | 118 |  |

Formula in D2, filled to D5: `=(B2-C2)/B2`

Result: 46.2%; 34.9%; 33.0%; 37.7%

## How it works

Margin is profit divided by the selling price: the share of each sale you keep. The brackets make Excel subtract before dividing. Markup is different: it divides profit by cost, so the same product has a higher markup than margin.

## Other ways

- `=1-C2/B2`: The same margin: one minus the cost share of the price.
- `=(B2-C2)/C2`: Markup, not margin: profit as a percentage of cost. (Markup is higher than margin for the same product.)

## Common mistakes

- Mixing up margin and markup is the most common pricing mistake. A 50% markup is only a 33.3% margin.
- To set a price from a target margin, divide the cost by (1 - margin): `=C2/(1-40%)`.

## Questions

**What is the difference between margin and markup?**

Margin divides profit by price; markup divides profit by cost.

**How do I calculate gross margin for a whole report?**

Use totals: `=(SUM(B2:B5)-SUM(C2:C5))/SUM(B2:B5)`, not the average of the row margins.

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

Source: https://spreadsheetpractice.com/formulas/profit-margin
