Function Problems

Automatically Update Stock from Sales and Purchases in Excel 2019

Camila MilosovichCamila Milosovich Dec 2, 2026 868 views

Question details

Calculate available inventory automatically from opening stock, sales, and purchases across worksheets.

Automatically Update Stock from Sales and Purchases in Excel 2019
Product
Microsoft Excel 2019
Device & OS
not provided
Scenario
The user records sales and purchases on separate worksheets and wants a stock worksheet to show the current quantity for each product.
Observed behavior
Available stock should decrease when sales are entered and increase when purchases are recorded.
Before you start

Identify the product ID and quantity columns on each worksheet, and make sure the same product IDs are used consistently. The example below uses separate Stock, Sales, and Purchases sheets with positive numeric quantities.

Solution 1Recommended

Calculate available stock with SUMIF across worksheets

Use this formula to total purchases and sales for each product and combine them with opening stock.

1
Set up the stock sheet

On the Stock worksheet, enter product IDs in column A and opening quantities in column B, starting in row 2. Label column C Available Stock.

2
Set up transaction sheets

On both the Sales and Purchases worksheets, enter product IDs in column A and positive transaction quantities in column B, starting in row 2.

3
Enter the inventory formula

On Stock, select cell C2 and enter =B2+SUMIF(Purchases!$A:$A,A2,Purchases!$B:$B)-SUMIF(Sales!$A:$A,A2,Sales!$B:$B). Press Enter.

4
Apply and test the formula

Drag the fill handle from C2 down column C for the other products. Add a matching product ID and quantity to Sales or Purchases and check that its available stock changes.

5
Check calculation settings

If the result does not update, select Formulas > Calculation Options > Automatic, then check that the transaction product ID matches the ID on Stock.

Calculate available stock with SUMIF across worksheets
Adjust the references for your workbook: Change the sheet names and column references if your layout differs. Enclose sheet names containing spaces in single quotes, such as 'Sales Data'!$A:$A.
Manage inventory in WPS Spreadsheet

Track sales and purchases with WPS Spreadsheet

Use SUMIF in WPS Spreadsheet to link sales and purchase entries to an available-stock calculation for each product.

  1. 1. Open the workbook: Open WPS Spreadsheet and use Open to select your Excel workbook, or create a new workbook.
  2. 2. Arrange the worksheets: On Stock, put product IDs in column A and opening quantities in column B. On Sales and Purchases, put product IDs in column A and transaction quantities in column B.
  3. 3. Calculate stock: Select Stock!C2 and enter =B2+SUMIF(Purchases!$A:$A,A2,Purchases!$B:$B)-SUMIF(Sales!$A:$A,A2,Sales!$B:$B), then press Enter.
  4. 4. Fill down and test: Drag the fill handle down column C, then add a matching transaction on Sales or Purchases to check the result.
Calculate available stock from opening quantities, purchases, and salesOpen and save Microsoft Excel XLSX workbooksUse familiar spreadsheet formulas and worksheet tabs
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my stock quantity updating?

In Excel, check Formulas > Calculation Options > Automatic. Also verify that product IDs match across sheets, quantities are numeric, and the formula references the correct columns.

Will the formula include new sales and purchases?

Yes. The example uses whole-column references, so new entries in columns A and B on Sales or Purchases are included when their product IDs match the Stock row.

How do I reference a worksheet with spaces in its name?

Put the sheet name in single quotes before the exclamation mark. For example, use 'Sales Data'!$A:$A in place of Sales!$A:$A.

Does the formula change my opening stock?

No. It reads the opening quantity in Stock column B and displays the calculated available quantity in column C; it does not overwrite the opening quantity.