Automatically Update Stock from Sales and Purchases in Excel 2019
Question details
Calculate available inventory automatically from opening stock, sales, and purchases across worksheets.

- 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.
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.
Calculate available stock with SUMIF across worksheets
Use this formula to total purchases and sales for each product and combine them with opening stock.
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.
On both the Sales and Purchases worksheets, enter product IDs in column A and positive transaction quantities in column B, starting in row 2.
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.
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.
If the result does not update, select Formulas > Calculation Options > Automatic, then check that the transaction product ID matches the ID on Stock.

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. Open the workbook: Open WPS Spreadsheet and use Open to select your Excel workbook, or create a new workbook.
- 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. 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. Fill down and test: Drag the fill handle down column C, then add a matching transaction on Sales or Purchases to check the result.

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.




