Function Problems

Create an Excel Invoice with Multiple Line Items

John WilsonJohn Wilson Dec 2, 2026 868 views

Question details

Create an invoice that retrieves customer and product data from a master sheet and displays all matching line items.

Create an Excel Invoice with Multiple Line Items
Product
Microsoft Excel
Device & OS
not provided
Scenario
An invoice needs to show four or five products associated with the same invoice number.
Observed behavior
VLOOKUP returns only one matching item instead of the multiple items needed on the invoice.
Before you start

Make sure each line item has an invoice number and that matching invoice numbers use the same format. Check whether your Excel version supports FILTER; if not, use the helper-column method.

Solution 1Recommended

Return matching invoice items with FILTER

Use FILTER in a supported Excel version to return all line items for the selected invoice number.

1
Create the item table

On the master sheet, select the item data and choose Insert > Table. On the Table Design tab, name the table ItemTable and make sure it has an InvoiceNumber column.

2
Enter the invoice number

On the invoice sheet, enter the invoice number in cell B2. Leave enough empty cells below and to the right of the line-item area for the results.

3
Filter the line items

In the first cell of the line-item area, enter =FILTER(ItemTable,ItemTable[InvoiceNumber]=$B$2,""). The matching table rows spill into the surrounding cells.

4
Retrieve customer details

For a single customer field, use a lookup against a customer table. For example, if B3 contains the customer ID, enter =XLOOKUP($B$3,CustomerTable[CustomerID],CustomerTable[CustomerName],"") in the customer-name cell.

Return matching invoice items with FILTER
Allow room for results: Place the FILTER formula outside an Excel table and clear any cells blocking its spill range. The formula returns all columns of ItemTable; arrange the source columns to suit the invoice.
Build your invoice in WPS Spreadsheets

Create a multi-item invoice in WPS Spreadsheets

Use a helper column with INDEX and MATCH in WPS Spreadsheets to retrieve successive line items for an invoice. Open an existing Excel workbook or create a new one.

  1. 1. Open the workbook: In WPS Spreadsheets, open your Excel workbook or create a workbook with a Master sheet and an invoice sheet.
  2. 2. Arrange the source data: On Master, place invoice numbers in column A and product names in column B, starting in row 2. Keep other item fields in separate columns.
  3. 3. Add a helper key: In Master!H2, enter =A2&"|"&COUNTIF($A$2:A2,A2), then fill the formula down for all item rows.
  4. 4. Retrieve the products: Enter the invoice number in B2 on the invoice sheet. In the first product cell, enter =IFERROR(INDEX(Master!$B$2:$B$1000,MATCH($B$2&"|"&ROWS($A$1:A1),Master!$H$2:$H$1000,0)),"") and copy it down for each invoice row.
  5. 5. Add the remaining fields: Copy the formula into adjacent columns and change the INDEX range to the relevant quantity or price column. Use a separate lookup against your customer table for customer details.
Retrieve multiple invoice items using familiar spreadsheet formulasOpen and edit Microsoft Excel XLSX and XLS filesCreate fixed invoice rows for products, quantities, and pricesUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does VLOOKUP return only one invoice item?

VLOOKUP returns the first matching value, not every matching row. Use FILTER to return all matching rows, or use a numbered helper key with INDEX and MATCH to retrieve them one at a time.

What if FILTER returns a spill error?

Clear the cells below and to the right of the FILTER formula, and place the formula outside an Excel table. The full result range must be empty.

How can I show only five line items with the helper-column method?

Copy the INDEX and MATCH formula down into five invoice rows. If the invoice has fewer matches, IFERROR leaves the remaining rows blank; if it has more, add rows to display them.

How do I retrieve a customer name separately from the items?

Use a unique customer ID in a lookup against your customer table. For example, enter =XLOOKUP($B$3,CustomerTable[CustomerID],CustomerTable[CustomerName],"") where B3 contains the customer ID.