How to Calculate Margin in Excel (Formula + Example)

๐Ÿ“… Updated August 26, 2026 โฑ 6 min read โœ๏ธ By Anchor AI Tools
Excel spreadsheet showing revenue and cost columns used to calculate profit margin

Profit margin tells you what percentage of your revenue is actually profit after costs. Excel calculates it in one formula โ€” no separate add-in or complex model required โ€” as long as you know your revenue and your cost.

This guide from Anchor AI Tools covers the exact formula, the difference between margin and markup (a mix-up that leads to real pricing mistakes), and a worked example across multiple products.

Quick Answer: To calculate margin in Excel, subtract cost from revenue, then divide by revenue: =(B2-C2)/B2, where B2 is revenue and C2 is cost. Format the result as a percentage. For example, a product that sells for $80 and costs $50 has a margin of 37.5%.

The Margin Formula

=(Revenue - Cost) / Revenue

Format the result as a percentage

In plain terms: Margin % = Profit รท Revenue. It answers "of every dollar I bring in, how much is actually profit?" โ€” which is different from asking how much profit is relative to cost (that's markup, covered below).

Step-by-Step in Excel

  1. Enter revenue in one column. For example, selling price in column B.
  2. Enter cost in the next column. Cost of goods sold in column C.
  3. Subtract cost from revenue, then divide by revenue. =(B2-C2)/B2.
  4. Format the result as a percentage. Select the cell, then Home โ†’ Number Format โ†’ Percentage, or press Ctrl+Shift+%.
// Margin: revenue in B2, cost in C2
=(B2-C2)/B2

Worked Example

A small retailer wants to check the margin on three products.

ProductRevenue ($)Cost ($)Margin
Product A805037.5%
Product B1209025.0%
Product C451860.0%

๐Ÿ“‹ Formula Used

With revenue in B2 and cost in C2, copied down each row:

=(B2-C2)/B2
Product A margin: 37.5%

Even though Product C brings in less revenue than Product A or B, it has by far the best margin โ€” 60% of every dollar it earns is profit, compared to 25% for Product B. Margin often tells a different story than revenue alone.

Gross Margin vs. Net Margin

TypeWhat It IncludesExcel Formula
Gross MarginRevenue minus direct cost of goods sold (COGS) only=(Revenue-COGS)/Revenue
Net MarginRevenue minus all costs โ€” COGS, overhead, taxes, interest=NetIncome/Revenue

Gross margin is useful for pricing individual products. Net margin gives the full picture of business profitability once every expense is accounted for โ€” the two numbers can look very different for the same business.

Margin vs. Markup โ€” Don't Confuse Them

Margin and markup use the same two numbers โ€” revenue and cost โ€” but divide by a different base, and mixing them up is one of the most common small-business pricing mistakes.

Margin = Profit รท Revenue  ยท  Markup = Profit รท Cost

Same profit amount, different denominator, very different percentages

Using the Product A example above ($80 revenue, $50 cost, $30 profit): margin is 30 รท 80 = 37.5%, but markup is 30 รท 50 = 60%. Pricing a product to hit a "50% margin" by simply adding 50% to cost actually only produces a 33.3% margin โ€” a mistake that quietly erodes profitability across every sale.

Common Mistakes to Avoid

Dividing by cost instead of revenue. This calculates markup, not margin โ€” the two numbers are not interchangeable, and using the wrong one in a pricing decision compounds across every sale.

Forgetting to format as a percentage. A margin formula without percentage formatting shows a confusing decimal like 0.375 instead of 37.5%.

Mixing gross and net margin without labeling which one you mean. A "40% margin" claim is meaningless without specifying gross or net โ€” they can differ substantially.

Using negative or zero revenue. If revenue is zero, the formula returns a #DIV/0! error โ€” wrap it in IFERROR if you're calculating margin across many rows that might include blanks.

Who Needs to Calculate Margin in Excel?

This comes up constantly for small business owners setting or reviewing prices, freelancers and agencies checking project profitability, e-commerce sellers comparing product performance, and finance teams building pricing or budgeting models.

Also checking a typical value in your sales data? See our guide on how to calculate median in Excel. Need a quick percentage calculation instead of a full spreadsheet? Try our percentage calculator.

Need more free calculators and formula guides?

Explore Free Tools โ†’

Frequently Asked Questions

What is the formula for margin in Excel?
=(Revenue-Cost)/Revenue, formatted as a percentage. For example, =(B2-C2)/B2 with revenue in B2 and cost in C2.
Is margin the same as markup?
No. Margin divides profit by revenue; markup divides profit by cost. The same $30 profit on a $50 cost item is a 37.5% margin but a 60% markup โ€” they answer different questions.
How do I calculate gross margin percentage in Excel?
Subtract cost of goods sold from revenue, divide by revenue, and format as a percentage: =(Revenue-COGS)/Revenue.
Why is my margin formula showing a decimal instead of a percentage?
The calculation is correct โ€” you just need to format the cell as a percentage. Select the cell, then Home โ†’ Number Format โ†’ Percentage.
What's a good profit margin?
It varies widely by industry โ€” retail and grocery often run thin single-digit margins, while software and services can run 60โ€“80%+. Compare your margin to others in your specific industry rather than a universal benchmark.
How do I calculate margin for many products at once?
Enter the formula once for the first row, then copy it down the column โ€” Excel automatically adjusts the cell references for each row.

Related Free Guides & Tools From Anchor AI Tools

โš ๏ธ Accuracy Note: This guide explains a standard business formula for planning and educational purposes. For pricing, tax, or accounting decisions, confirm your figures with a qualified accountant or financial professional.
A
Anchor AI Tools Editorial Team

We build free, fast, and accurate online tools and guides that explain the answer โ€” not just show a number. Used by small business owners, analysts, and freelancers every day.

Published by Anchor AI Tools ยท ยฉ 2026 Anchor AI Tools