How to Calculate Profit Margin in Excel
Profit margin tells you how much of each dollar of revenue you actually keep. It's one number every business owner should be able to pull from a spreadsheet in seconds. Here's how to calculate it in Excel correctly.
The core formula. Profit margin is profit divided by revenue:
=(Revenue - Cost) / Revenue
With revenue in B2 and cost in C2:
=(B2-C2)/B2
Format the cell as a percentage (Ctrl+Shift+%) and you'll see, say, 35% rather than 0.35.
Gross vs operating vs net margin. The formula is the same; what changes is which costs you subtract.
- Gross margin uses only the cost of goods sold (COGS):
=(Revenue-COGS)/Revenue. - Operating margin subtracts COGS plus operating expenses.
- Net margin subtracts all costs including tax and interest:
=(Revenue-TotalCosts)/Revenue.
Pick the one that answers your question — gross margin for product pricing, net margin for overall profitability.
Margin vs markup — don't confuse them. This is the most common mistake. Margin is profit as a percentage of the selling price. Markup is profit as a percentage of the cost:
Margin: =(Price-Cost)/Price
Markup: =(Price-Cost)/Cost
A product that costs $60 and sells for $100 has a 40% margin but a 67% markup. Same dollars, different denominator — and quoting the wrong one to a client can be an expensive error.
Working backwards. To find the price needed for a target margin, rearrange the formula. For a 40% target margin on a $60 cost:
=Cost/(1-TargetMargin) → =60/(1-0.4) → $100
This is gold for pricing: set the margin you want, get the price.
Guard against divide-by-zero. If revenue can be blank or zero, wrap it:
=IF(B2=0,"",(B2-C2)/B2)
so a draft row shows nothing instead of #DIV/0!.
Build a margin column once. Drop the formula in the first data row, format as a percentage, and fill down. Add conditional formatting to highlight any product under your minimum acceptable margin and unprofitable lines jump out instantly.
Related: 10 Excel Formulas Every Small Business Owner Should Know · Profit Calculator Template