The Excel formula for margin is =(price − cost) / price, then format the result cell as a percentage. If your selling price sits in cell C2 and your cost in cell B2, you type =(C2-B2)/C2 and press Enter. That returns margin as a share of the price — not markup over cost, which is a different number entirely.

Most spreadsheets get this wrong in the same place: they divide the profit by the cost instead of the price. That single swap turns a margin into a markup, and the two are never equal. This guide gives you the exact formula, the cell-by-cell setup, and the profit angle almost every other "margin in Excel" page skips.

The core Excel formula for margin

Margin measures profit as a percentage of revenue. So the numerator is your profit (price minus cost) and the denominator is the price you charge.

The Excel formula for margin is:

=(price - cost) / price

This matches the standard convention shown on reference sites like Exceljet, where the generic form is written as =(price-cost)/price. The result comes back as a decimal such as 0.60, which you then format as a percentage to read it as 60%.

Step by step in a spreadsheet

Say you sell a printed hoodie for $40 that costs you $16 to make and fulfill. Here is the exact build:

  1. Put the price in cell C2: 40.
  2. Put the cost in cell B2: 16.
  3. In cell D2, type the margin formula: =(C2-B2)/C2.
  4. Press Enter. Excel shows 0.6.
  5. Select D2, then press Ctrl+Shift+% (or click the % button on the Home tab) to format it as a percentage. It now reads 60%.

To calculate the dollar profit alongside the percentage, add one more cell. In E2, type =C2-B2, which returns $24. That $24 is your gross profit per unit, and 60% is that same profit expressed against the price.

If you have a whole product list, put the formula in the first row and drag the fill handle down. Lock nothing — the relative references C2 and B2 shift correctly row by row, so C3/B3, C4/B4, and so on all calculate on their own line.

The Excel formula for profit margin: gross, operating, net

"Profit margin" is a family of ratios, not one number. They share a shape — some profit figure divided by revenue — but subtract different costs. The excel formula for profit margin depends on which layer you mean.

  • Gross profit margin: =(Revenue - COGS) / Revenue. COGS is the direct cost of the goods themselves. This is the same calculation as the core margin formula above.
  • Operating profit margin: =(Revenue - COGS - Operating Expenses) / Revenue. This nets out rent, software, and salaries too.
  • Net profit margin: =(Net Profit) / Revenue, where net profit is what remains after every cost, including interest and tax.

In a spreadsheet with revenue in C2, COGS in B2, and operating costs in F2, your operating margin cell would read =(C2-B2-F2)/C2. The three-step method is always the same: build the profit numerator, divide by revenue, format as a percentage.

For a deeper walk through how these ratios connect to the rest of your store's numbers, our ecommerce metrics guide lays out each formula with worked units.

The Excel formula for margin percentage vs markup

This is the trap. Margin and markup describe the same dollar gap, but against different denominators — and confusing them is a classic pricing error.

  • Margin is the gap over price: =(price - cost) / price.
  • Markup is the gap over cost: =(price - cost) / cost.

Using the hoodie again, price $40 and cost $16:

  • Margin: (40 - 16) / 40 = 0.6060% margin.
  • Markup: (40 - 16) / 16 = 1.50150% markup.

Same $24 gap, two very different percentages. A supplier who tells you they apply a "50% markup" is not giving you a 50% margin — a 50% markup on cost is only a 33% margin on price.

To convert between them in Excel:

  • Margin from markup: =markup / (1 + markup). With a markup of 1.5: 1.5 / 2.5 = 0.60.
  • Markup from margin: =margin / (1 - margin). With a margin of 0.6: 0.6 / 0.4 = 1.5.

If you price your catalog off a target margin, the second formula is the one you want: it tells you the markup multiplier to apply to each item's cost so every product lands at the same margin.

A worked example: from margin to true per-order profit

Gross margin is where most sellers stop — and where the number stops being honest. A 60% gross margin on a $40 order sounds healthy, but it ignores everything else that leaves your bank account on that same sale.

Say you sell that $40 hoodie. Here is what actually comes out per order:

Line Amount
Revenue $40.00
− Product cost (COGS) −$16.00
= Gross profit (60% margin) $24.00
− Shipping −$5.00
− Payment processing (4% of $40) −$1.60
− Pick and pack labor −$1.40
= Contribution margin before ads $16.00
− Ad spend allocated to the order −$10.00
= Profit after ads $6.00

The 60% gross margin quietly becomes a 15% margin once ads and variable costs are in. In Excel, contribution margin is =(C2 - B2 - shipping - fees - labor) and the post-ad figure subtracts one more term. The formula shape never changes; you just keep subtracting real cost lines.

This is the number that decides whether growth is safe. A campaign at a 4.0 return on ad spend looks great on the platform, yet on a thin margin it can still lose money per order. If you want the acquisition side of this math, our CPA calculator walkthrough shows how ad cost per order eats into that $16.

Where a spreadsheet stops being enough

A margin formula in Excel is perfect for one product at rest. It breaks down when the inputs move — supplier prices change, shipping varies by order, payment fees float, and ad spend has to be split across hundreds of orders that each carry different real costs.

At that point you are maintaining a spreadsheet instead of running a store. Metrics like lifetime value and repeat rate also stop being one-cell formulas; see how ARPU and LTV differ and how RFM segmentation reshapes an "average" margin once you look at who is actually buying.

This is the gap PodVector closes. It connects your Shopify store with Meta Ads, Google Ads, Printify, and Printful, then computes the true per-order profit — the $6 line above, not the $24 one — automatically across every order. Victor, the built-in AI operator, reads that live data, surfaces which products and campaigns are actually profitable, and can take Shopify-side actions with your approval. He reads your ad data to make the call, but does not touch your ad account. Victor is not a dashboard you have to babysit; he analyzes and acts.

See your true per-order margin with PodVector

FAQs

What is the Excel formula for margin?

The Excel formula for margin is =(price - cost) / price, formatted as a percentage. With price in C2 and cost in B2, you type =(C2-B2)/C2. It expresses profit as a share of the selling price.

What is the Excel formula for profit margin?

For gross profit margin, use =(Revenue - COGS) / Revenue. For operating margin, subtract operating expenses too: =(Revenue - COGS - OpEx) / Revenue. Net margin divides net profit — what is left after all costs — by revenue. Each result is formatted as a percentage.

How do I calculate margin percentage in Excel?

Build the formula, then format the cell. Type =(C2-B2)/C2 to get a decimal like 0.6, select the cell, and press Ctrl+Shift+% to convert it to 60%. The excel formula for margin percentage is the same formula plus percentage formatting — the formatting is what turns 0.6 into 60%.

Why is my Excel margin higher than expected?

You are almost certainly dividing by cost instead of price, which gives markup, not margin. (40-16)/16 is 150% markup; (40-16)/40 is 60% margin. Check that your denominator is the selling price.

Is margin the same as markup in Excel?

No. Margin divides the profit by the price; markup divides the same profit by the cost. A 60% margin equals a 150% markup on the identical $40 price and $16 cost. Always confirm which denominator a supplier or spreadsheet is using before comparing numbers.

Does gross margin tell me if an order is profitable?

Not on its own. Gross margin only subtracts product cost. Real per-order profit also nets out shipping, payment fees, fulfillment labor, and the ad spend it took to win the sale — which can turn a 60% gross margin into a much thinner number. To judge whether a sale actually pays, calculate contribution margin after ads, not gross margin.