Quick answer: A spreadsheet can calculate both margin and markup from the same two input cells. The key is using the correct denominator and handling zero safely.
Try it: Open the free BuzBolt Profit Margin Calculator. No signup is required.
Understand the method
If A2 contains cost and B2 contains selling price, gross profit is =B2-A2, margin is =IF(B2=0,"",(B2-A2)/B2) and markup is =IF(A2=0,"",(B2-A2)/A2). Format the last two cells as percentages.
The empty result is intentional when the denominator is zero. Whether to show “not defined” or a blank depends on your spreadsheet use.
Worked example
With A2 = 75 and B2 = 120, gross profit is 45, margin is 37.5% and markup is 60%.
What people often get wrong
If you type *100 into a formula and then format the cell as a percentage, it may display a result 100 times too large.
A practical way to use this
Create separate columns for cost, selling price, gross profit, margin and markup; lock formula columns if many people edit the sheet.
Frequently asked question
Can margin be negative in Excel? Yes, when selling price is positive but below cost.
Spreadsheet formulas avoid mental shortcuts
With cost in A2 and selling price in B2, =(B2-A2)/B2 calculates margin when B2 is nonzero; =(B2-A2)/A2 calculates markup when A2 is nonzero. Format the result cell as a percentage.
Apply it to your own task
A more explicit version checks the denominator: =IF(B2=0,"N/A",(B2-A2)/B2) for margin. For markup use =IF(A2=0,"N/A",(B2-A2)/A2). Keep both columns labelled.
Related reading
BuzBolt provides general educational tools and explanations. Check your inputs and confirm any legal, tax, accounting or workplace-specific requirements independently where relevant.