Function Problems

Create an Excel Inventory and Invoice System with Automatic Stock Updates

Maira MehtabMaira Mehtab Nov 18, 2026 872 views

Question details

Create an invoice that retrieves inventory details, records quantities sold, and calculates current stock.

Create an Excel Inventory and Invoice System with Automatic Stock Updates
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user wants to prepare invoices and track inventory in the same workbook.
Observed behavior
Invoice lines should show item details and totals, while stock levels reflect recorded receipts and sales.
Before you start

List each item with a unique SKU, description, unit price, and opening stock. The XLOOKUP formulas below require a version of Excel that supports XLOOKUP.

Solution 1Recommended

Build invoice and inventory tables with a transaction ledger

Use this method to retrieve invoice details and recalculate stock whenever a sale or receipt is recorded.

Stock updates automatically after transactions are entered, but formulas alone do not copy invoice lines into the transaction ledger. Record each completed sale there once; an automated posting process would require additional tools or automation.

1
Create the inventory table

On an Inventory sheet, enter columns named SKU, Description, Unit Price, Opening Stock, and Current Stock. Select the data, choose Insert > Table, and name the table Inventory in Table Design.

2
Create the transaction table

On a Transactions sheet, create a table named Transactions with SKU, Type, Quantity, Reference, and Unit Price columns. Use positive quantities and enter either Sale or Receipt in the Type column.

3
Calculate current stock

In Inventory[Current Stock], enter =[@[Opening Stock]]+SUMIFS(Transactions[Quantity],Transactions[SKU],[@SKU],Transactions[Type],"Receipt")-SUMIFS(Transactions[Quantity],Transactions[SKU],[@SKU],Transactions[Type],"Sale"). Excel fills the calculated column as you add items.

4
Set up invoice lines

On an Invoice sheet, create a table named InvoiceLines with SKU, Quantity, Description, Unit Price, and Line Total columns. Enter SKUs and quantities for the items being sold.

5
Retrieve details and calculate totals

In InvoiceLines[Description], enter =XLOOKUP([@SKU],Inventory[SKU],Inventory[Description],"SKU not found"). In Unit Price, enter =XLOOKUP([@SKU],Inventory[SKU],Inventory[Unit Price],""). In Line Total, enter =IF([@[Unit Price]]="","",[@Quantity]*[@[Unit Price]]). Add =SUM(InvoiceLines[Line Total]) below the table for the invoice total.

6
Record completed sales and receipts

For each completed invoice line, add a Sale row to Transactions with its SKU, positive quantity, invoice reference, and charged unit price. Add received stock as Receipt rows. Check the reference before entering a sale to avoid recording it twice.

Build invoice and inventory tables with a transaction ledger
Preserve charged prices: Invoice lookup prices change if the inventory price changes. Record the charged unit price in Transactions and retain a fixed copy of each completed invoice for historical records.
Build it in WPS Spreadsheets

Track invoice sales and stock in WPS Spreadsheets

Create an inventory workbook in WPS Spreadsheets using lookup formulas for invoice lines and SUMIFS to calculate stock from a transaction ledger.

  1. 1. Set up inventory: Open WPS Spreadsheets and create an Inventory sheet. Put SKU, Description, Unit Price, Opening Stock, and Current Stock in columns A through E, then enter one item per row.
  2. 2. Create a ledger: Add a Transactions sheet with SKU, Type, Quantity, Reference, and Unit Price in columns A through E. Enter positive quantities and use Sale or Receipt as the type.
  3. 3. Calculate stock: In Inventory!E2, enter =D2+SUMIFS(Transactions!$C$2:$C$1000,Transactions!$A$2:$A$1000,A2,Transactions!$B$2:$B$1000,"Receipt")-SUMIFS(Transactions!$C$2:$C$1000,Transactions!$A$2:$A$1000,A2,Transactions!$B$2:$B$1000,"Sale"), then fill the formula down.
  4. 4. Build invoice lines: Add an Invoice sheet with SKU, Quantity, Description, Unit Price, and Line Total in columns A through E. In C2, enter =IFERROR(VLOOKUP(A2,Inventory!$A$2:$C$1000,2,FALSE),"SKU not found"); in D2, use =IFERROR(VLOOKUP(A2,Inventory!$A$2:$C$1000,3,FALSE),""); and in E2, use =IF(D2="","",B2*D2). Fill these formulas down.
  5. 5. Record each completed sale: Enter each completed invoice line once on the Transactions sheet, including its invoice reference and charged price. Current stock recalculates after the sale is entered; formulas do not post invoice lines to the ledger automatically.
Calculate current stock from recorded sales and receiptsRetrieve item descriptions and prices for invoice linesOpen and save Microsoft Excel XLSX workbooksUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does entering an invoice line not reduce stock immediately?

The stock formula uses the Transactions ledger, not draft invoice lines. Add each completed line as a Sale in the Transactions table to update stock. Posting lines automatically requires additional automation.

How do I add newly received inventory?

Add a row to the Transactions table with the item SKU, Receipt as the type, and a positive quantity. The current-stock formula adds it to opening stock.

What should I do if an invoice says the SKU was not found?

Check that the SKU in the InvoiceLines table exactly matches a SKU in Inventory. Add the item to Inventory if it is missing, then check the invoice line again.

How can I keep an old invoice price from changing?

Record the charged price in the Transactions table and retain a fixed copy of the completed invoice. A live lookup formula will otherwise reflect changes to the inventory price.

Can I use this workbook without XLOOKUP?

Yes. Use VLOOKUP or INDEX and MATCH to retrieve descriptions and prices. The WPS Spreadsheets steps show a VLOOKUP example.