Create an Excel Invoice with Multiple Line Items
Question details
Create an invoice that retrieves customer and product data from a master sheet and displays all matching 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.
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.
Return matching invoice items with FILTER
Use FILTER in a supported Excel version to return all line items for the selected invoice number.
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.
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.
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.
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.

Retrieve successive matches with a helper column and INDEX
Use this method when FILTER is unavailable or when you want a fixed number of invoice rows.
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. Open the workbook: In WPS Spreadsheets, open your Excel workbook or create a workbook with a Master sheet and an invoice sheet.
- 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. Add a helper key: In Master!H2, enter =A2&"|"&COUNTIF($A$2:A2,A2), then fill the formula down for all item rows.
- 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. 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.

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.




