=(B2-A2)/B2, press Enter, then format the cell as a percentage. That returns your margin as a share of revenue — a $40 sale on a $16 cost shows 60%.
Margin is one of the most useful numbers a store owner can pull in a spreadsheet, and it takes a single formula. But the formula is the easy part. The trap is confusing margin with markup, and then assuming the percentage on your screen equals the money in your pocket. It usually doesn't.
This guide gives you the exact Excel formulas, walks a real calculation with numbers, and then shows the piece almost every other article skips: how to translate that percentage into actual per-order profit.
The Excel formula to calculate margin
Margin measures profit as a share of the selling price. The formula is:
Margin % = (Selling Price − Cost) ÷ Selling Price
In Excel, put your cost in column A and your selling price in column B. Then in column C, type:
=(B2-A2)/B2
That's the whole thing. The result comes back as a decimal like 0.6, so format it as a percentage to read it as 60%.
Step by step in Excel
Say you sell a hoodie. Here is the exact sequence:
- In cell A2, enter your cost:
16. - In cell B2, enter your selling price:
40. - In cell C2, enter
=(B2-A2)/B2. - Select C2, then click the percent (%) button on the Home tab.
Excel returns 60%. The math underneath is (40 − 16) ÷ 40 = 0.60. That means 60 cents of every revenue dollar is left after the product cost — the other 40 cents went to making or buying the item.
To calculate margin for a whole product list, drag the formula down the column. Excel adjusts the row references automatically, so C3 reads =(B3-A3)/B3, and so on.
Gross, operating, and net margin formulas in Excel
"Margin" is a family of metrics, not one number. They all share the same shape — a profit figure divided by revenue — but each subtracts a different set of costs.
- Gross margin:
=(Revenue − COGS) / Revenue. Subtracts only the cost of goods sold. This is the formula above. - Operating margin:
=(Revenue − COGS − Operating Expenses) / Revenue. Also nets out overhead like software, rent, and salaries. - Net margin:
=Net Profit / Revenue. Subtracts everything, including interest and taxes — your true bottom line.
In a spreadsheet with revenue in B3, COGS in B5, and operating profit in B9, your gross margin cell is =B5/B3 if B5 already holds gross profit, and your net margin cell is =B13/B3 if B13 holds net profit. The pattern never changes: profit on top, revenue on the bottom.
The gap between these tiers is where money quietly disappears. A product can carry a healthy 60% gross margin and still land at a 5% net margin once every other cost is counted. For a fuller map of how these metrics connect, our ecommerce metrics guide walks the whole chain from revenue to net profit.
Margin vs markup: the classic mix-up
This is the single most common pricing error, and it costs stores real money.
- Margin is the gap over price:
=(Price − Cost) / Price. - Markup is the gap over cost:
=(Price − Cost) / Cost.
Same dollars, different denominator, very different percentages. Take that $16 cost and $40 price:
- Margin:
(40 − 16) ÷ 40 = 60% - Markup:
(40 − 16) ÷ 16 = 150%
A 150% markup is a 60% margin. They describe the identical $24 gap. If a supplier tells you to "add a 150% markup" and you instead set a 150% margin, you'll price the item far too high — or if you swap them the other way, far too low. Always know which one your number represents.
Convert between margin and markup in Excel
You don't need to recompute from scratch. These two Excel-ready conversions move between them directly:
- Markup to margin:
=Markup / (1 + Markup)→1.5 / 2.5 = 0.60 - Margin to markup:
=Margin / (1 − Margin)→0.60 / 0.40 = 1.5
If your margin is in cell C2, the markup cell is =C2/(1-C2). Our deeper walkthrough on the formula to add margin to cost shows how to price a product from a target margin without ever touching markup math by hand.
Work backward: sale price from a target margin
Often you know your cost and the margin you want, and you need the price. Rearranging the margin formula gives you:
Selling Price = Cost ÷ (1 − Margin %)
In Excel, with cost in A2 and your target margin (as a decimal) in C2:
=A2/(1-C2)
Say the hoodie costs $16 and you want a 60% margin. Then 16 ÷ (1 − 0.60) = 16 ÷ 0.40 = $40. Enter that once and you can flex the target margin cell to see instantly what price each goal demands. Drop the target to 50% and the same cost needs a 16 ÷ 0.50 = $32 price.
Why the margin percentage isn't your real profit
Here's the part the top-ranking Excel tutorials leave out. A 60% gross margin looks great on the screen, but it is not the profit you keep on an order. Gross margin only subtracts the product cost. Every real sale also carries shipping, payment fees, and pick-and-pack labor — and if you run ads, a slice of ad spend too.
Say you sell that $40 hoodie. Walk the full per-order math:
- Revenue: $40.00
- − Product cost (COGS): −$16.00 → gross profit $24.00 (60% margin)
- − Shipping: −$5.00
- − Payment processing (4% of $40): −$1.60
- − Pick and pack: −$1.40 → contribution margin before ads $16.00 (40%)
- − Ad spend allocated to the order: −$10.00 → profit after ads $6.00 (15%)
Same order, three very different margins: 60%, then 40%, then 15%. The =(B2-A2)/B2 formula only ever sees the first one. The real number a store lives on is the last one — and no single spreadsheet cell captures it unless you feed in every cost, per order, as it actually happens.
That gap between the tidy percentage and the messy reality is why margin math on ad-driven products gets slippery. A campaign can post a strong return on ad spend and still lose money once the true margin is netted out. We break down exactly that trap in ROI vs profit margin, and cover how scaling shifts the math in incremental gross margin.
From spreadsheet to live per-order profit
A spreadsheet is perfect for learning the formula and pricing a single product. It breaks down when you need the true margin on every order, updating as fees, shipping, and ad costs move.
That's the problem PodVector was built for. It connects your Shopify, Meta Ads, Google Ads, Printify, and Printful accounts and computes true per-order profit — the $6, not the $40 or the $24 — automatically, without you rebuilding a spreadsheet every week. Victor, its AI operator, analyzes that live data and proposes moves, taking Shopify-side actions only with your approval. Victor is not a dashboard, and he does not touch your ad account; he reads the data and hands you the decision.
If you'd rather stop reconciling costs by hand and see the margin that actually lands, you can start with PodVector free.
Once your margin is solid, the next lever is turning more visitors into buyers — our guide to Stripe checkout conversion rate picks up there.
FAQs
What is the Excel formula to calculate margin?
The core formula is =(B2-A2)/B2, where A2 is your cost and B2 is your selling price. It returns margin as a share of revenue. Format the result cell as a percentage so 0.6 reads as 60%. Drag it down a column to calculate margin for an entire product list at once.
How do I calculate margin percentage from cost and price in Excel?
Subtract cost from price, then divide by price: =(Price − Cost) / Price. With cost $16 and price $40, that's (40 − 16) ÷ 40 = 0.60, or 60%. The key is dividing by the price, not the cost — dividing by cost gives you markup instead, which is a larger and different number.
What's the difference between margin and markup?
Margin divides the profit gap by the selling price; markup divides the same gap by the cost. For a $16 cost and $40 price, that's a 60% margin but a 150% markup — identical dollars, different base. Suppliers usually quote markup; profit-and-loss statements use margin. Mixing them up is the most common pricing mistake in retail.
How do I calculate selling price from a target margin in Excel?
Use =Cost / (1 − Margin), entering the margin as a decimal. In Excel with cost in A2 and target margin in C2, that's =A2/(1-C2). A $16 cost at a 60% target margin needs a 16 ÷ 0.40 = $40 price. Change the target-margin cell and the required price updates instantly.
Why is my real profit lower than my margin percentage?
Because gross margin only subtracts the product cost. Your actual per-order profit also loses shipping, payment processing fees, fulfillment labor, and — for paid traffic — a share of ad spend. A 60% gross margin on a $40 order can shrink to a 15% margin, roughly $6, once every real cost is counted. The formula in Excel can't see those costs unless you enter them for each order.
Can Excel calculate margin for every order automatically?
Not on its own. A spreadsheet handles a fixed product list well, but it can't pull live shipping, fee, and ad-spend data per order as it changes. That's where a connected profit tool helps: PodVector links Shopify, Meta Ads, Google Ads, Printify, and Printful to compute true per-order profit continuously, so you see the margin that actually lands rather than the one the formula assumes.