Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Formula to Calculate Gross Profit Step by Step

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Gross profit is revenue minus the direct cost of the goods or services sold, and in Excel the formula is simply =Revenue - COGS, where COGS is cost of goods sold. Put revenue in one cell and COGS in the cell next to it, then subtract the second from the first. That is the whole calculation. The rest of this guide covers how to set the sheet up so the formula stays correct as rows grow, how to turn the figure into a gross margin percentage, and what usually goes wrong.

What You'll Need

  • A spreadsheet app that supports standard formulas - Excel for Windows or Mac, Excel for the web, or an equivalent such as Google Sheets or LibreOffice Calc. The formulas below work in all of them.
  • Two figures for each product, job or period: total revenue (or sales) and total cost of goods sold. If you only have unit prices and unit costs, you can multiply them out first - see step 2.
  • A clear decision on what counts as COGS. Include the materials, purchase cost of stock, freight inbound, and direct production labour; exclude rent, marketing, admin salaries and other overheads, which belong below the gross profit line.
  • One row per item or period, with a header row at the top. Consistent structure is what makes the formula copy cleanly down a column.

Step-by-Step

  1. Lay out the columns. In a blank sheet, put headers in row 1: A1 = Item, B1 = Units Sold, C1 = Unit Price, D1 = Unit Cost, E1 = Revenue, F1 = COGS, G1 = Gross Profit. If you already have revenue and COGS totals from your accounting system, you can skip B to D and use just A, E, F and G.
  2. Enter your data. Type plain numbers only - no currency symbols and no spaces. If you type 1,250 with a comma, Excel may read it as text depending on your regional settings, and text values break arithmetic. Format numbers as currency afterwards via Home > Number Format (labels vary slightly by version and region).
  3. Calculate revenue in E2. Click E2 and type =B2*C2, then press Enter. This multiplies units by unit price. If your revenue is already a single figure, just type the number in E2 instead.
  4. Calculate COGS in F2. Click F2 and type =B2*D2, or type the total cost directly if you have it. Again, the formula only applies if you are working from units and unit costs.
  5. Write the gross profit formula in G2. Type =E2-F2 and press Enter. That single subtraction is the answer. Do not wrap it in ROUND unless you specifically need to - keep the underlying precision and round only the display.
  6. Copy the formulas down. Select E2:G2, then drag the small square at the bottom-right corner of the selection down to your last data row, or copy the cells and paste into the range below. Because the references are relative, each row recalculates against its own values. Confirm by clicking a lower row and checking the formula bar shows that row's numbers.
  7. Add a total row. Below the last row, label the cell Total and use =SUM(G2:G100), adjusting the range to your last row. Extending the range well past your current data (for example to row 100) lets you add rows later without rewriting the total.
  8. Turn it into a gross margin percentage. In the next column, type =G2/E2, then apply the percentage format with Home > Percentage. Gross profit is a money amount; gross margin is that amount divided by revenue. Keeping both makes the report far more readable, because a big gross profit on huge revenue can still be a thin margin.
  9. Protect against error values. If a row has zero revenue, G2/E2 returns a division error. Use =IFERROR(G2/E2,"") to leave the cell blank instead, or better, keep zero-revenue rows out of the table.
  10. Check one row by hand. Pick any row, multiply the numbers on a calculator, and confirm the sheet matches. Verifying one row catches the most common setup mistakes before they spread through the workbook.

Worked example: 40 units at 25.00 each gives revenue of 1,000.00. Unit cost of 15.00 gives COGS of 600.00. Gross profit is =1000-600 = 400.00, and gross margin is =400/1000 = 40%.

Common Mistakes

  • Mixing overheads into COGS. Rent, software subscriptions and admin wages are operating expenses. Including them understates gross profit and leaves you with a number that is really operating profit.
  • Leaving numbers stored as text. Cells that look like numbers but are left-aligned are usually text. The subtraction then returns zero, a wrong result or an error. Fix with Data > Text to Columns and click Finish on the column, or retype the values.
  • Breaking references when copying. If you type =$E$2-$F$2 and copy down, every row points at row 2. Use relative references (E2-F2) for row-by-row copies and dollar signs only when you deliberately want a fixed cell.
  • Forgetting the minus sign direction. The formula is revenue minus cost. Reversing it gives a negative gross profit on every profitable sale.
  • Calculating margin but calling it profit. A percentage is a margin, not a profit figure. Label columns clearly so nobody reports 40 as 40 pounds or dollars.
  • Hidden rows left out of totals. SUM ignores rows you have filtered out manually but includes hidden ones. If the total looks wrong, check for hidden rows in the range.

Tips

  • Convert your data range to a table with Insert > Table. Formulas then extend automatically when you add a row, and totals appear without editing ranges.
  • Use absolute references only for fixed rates such as a single tax percentage, for example =E2*(1+$B$1).
  • Apply currency formatting to the profit column and percentage formatting to the margin column so the two never get confused.
  • For a monthly view, add a date column and calculate gross profit per month, then use a PivotTable to sum it by month - far safer than editing a static total row each period.
  • Keep one sheet for raw data (units, prices, costs) and a second for the summary. It makes auditing much easier when a number looks wrong.
  • Use Formulas > Show Formulas (Ctrl+` on Windows, Cmd+` on Mac) to display every formula at once and spot inconsistent rows quickly.

Troubleshooting

The result is zero. The most likely cause is text-formatted numbers, or a cell that contains a space between digits. Select the cells, set the format to General or Number, and retype one value to test. If the subtotal now changes, the rest are text too.

You see #VALUE!. One of the referenced cells contains text or an empty string, often from an imported file. Trace it with Formulas > Evaluate Formula, which walks through the calculation one step at a time.

You see #DIV/0! in the margin column. Revenue is zero or blank for that row. Wrap the division in IFERROR as described in step 9, or delete the empty row.

Every copied row shows the same number. The reference was locked with dollar signs. Edit the top formula, remove the dollar signs from row-relative cells, and copy down again.

The total is lower than expected. Check that your SUM range covers the last row, that hidden or filtered rows are not being counted differently than you think, and that no formula was overwritten by a typed value in a lower row.

If that did not work, rebuild one row from scratch in empty columns using the four-step formula chain, confirm it produces the expected figure, then compare each cell in the broken row with it. A single clean comparison usually locates the fault within a minute.

Frequently Asked Questions

What is the basic formula for gross profit in Excel?

Gross profit equals revenue minus cost of goods sold, written in a cell as =Revenue - COGS, for example =E2-F2.

How do I calculate gross profit margin instead?

Divide gross profit by revenue: =(E2-F2)/E2. Format the result as a percentage. This gives the share of each sale left after direct costs.

Can I calculate gross profit for a whole column at once?

Yes. Write the formula once in the first data row and copy it down, or use a table so it fills automatically. Then sum the column for the total gross profit.

Should shipping cost be included in COGS?

Inbound freight to get stock to you normally counts as a direct cost of acquiring the goods. Outbound shipping charged to customers is usually treated as revenue or an operating expense rather than COGS. Follow whichever convention your accounting records use, and apply it consistently.

Does gross profit include tax?

No. Use figures excluding sales tax or VAT, so tax you collect on behalf of the authorities is not counted as revenue. COGS should likewise exclude any recoverable tax.

Why does my gross profit figure not match my accountant's?

Different definitions of COGS are the usual reason - stock valuation methods, freight treatment, or whether direct labour is included. Ask which items they classify as cost of goods sold and align your columns to that list.