How to Transfer Product Quantities and Codes to an Excel Invoice
Question details
Build an automated Excel invoice using product codes, quantities, and lookup formulas to retrieve prices and calculate line totals.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating an efficient invoice template where entering a product code automatically populates the item description and price.
- Observed behavior
- Manual data entry is currently required for descriptions and prices, leading to slow processing times and calculation errors.
Ensure you have a normalized price list or product database set up in a separate worksheet within your workbook, featuring clear columns for product codes, descriptions, and unit prices.
Use VLOOKUP and Data Validation to Automate the Invoice
Create a drop-down list for product codes and use the VLOOKUP function to automatically fetch product descriptions and prices based on the selected code.
This method involves setting up a structured product database and using standard lookup formulas. By implementing Data Validation, you ensure that only valid product codes are entered, reducing errors.
Create a new worksheet named 'Products'. In columns A, B, and C, enter your Product Codes, Descriptions, and Retail Prices respectively.
Go to your Invoice worksheet. Select the cells where product codes will be entered. Click on the 'Data' tab, select 'Data Validation', choose 'List' under the Allow criteria, and select the Product Code column from your 'Products' sheet.
In the Description column of your invoice, enter the formula: =VLOOKUP(A2, Products!A:C, 2, FALSE). This tells Excel to look for the code in cell A2 and return the exact match from the second column of your product list.
In the Unit Price column of your invoice, enter: =VLOOKUP(A2, Products!A:C, 3, FALSE). This retrieves the price from the third column of the product database.
In the Total column, enter the formula: =QuantityCell * PriceCell (e.g., =B2*D2) to multiply the manually entered quantity by the automatically fetched unit price.

Use XLOOKUP for Flexible Multi-Criteria Retrieval
Utilize the newer XLOOKUP function as a more flexible alternative, especially useful if your product codes are not in the first column or if you need to search based on multiple criteria.
Automate Your Spreadsheets with WPS Office
WPS Spreadsheet provides powerful built-in functions like VLOOKUP, XLOOKUP, and Data Validation to help you build automated, error-free invoices quickly and accurately.
- 1. Create your workbook: Open WPS Spreadsheet and create a new blank workbook to serve as your automated invoice.
- 2. Set up your database: Input your product codes, descriptions, and prices into 'Sheet2'.
- 3. Apply Data Validation: On your invoice template in 'Sheet1', navigate to the 'Data' tab and click 'Validation' to create drop-down menus for your product codes.
- 4. Insert lookup formulas: Use standard VLOOKUP or XLOOKUP formulas exactly as you would in Microsoft Excel to automatically pull in your product details.

Frequently Asked Questions
Why is my VLOOKUP formula returning an #N/A error on the invoice?
The #N/A error usually occurs when the product code entered on the invoice cannot be found in the first column of your product list. Ensure that there are no trailing spaces and that the data formats (text versus numbers) match exactly in both sheets.
How do I keep the invoice cells blank when no product code is selected?
You can wrap your VLOOKUP formula in an IFERROR function. Use the formula: =IFERROR(VLOOKUP(A2, Products!A:C, 2, FALSE), ""). This will display a blank cell instead of an error message when a product code is not yet selected.
Can I look up a product price using multiple criteria, such as item code and color?
Yes. While standard VLOOKUP only handles a single criterion, you can use XLOOKUP with concatenated criteria. For example, use =XLOOKUP(CodeCell&ColorCell, ProductCodes&ProductColors, Prices) to fetch details based on both the item code and its color.




