Create Multiple Bills in Excel Using Formulas and Macros
Question details
Generate multiple bills from an Excel data table without manually copying each account's information.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user wants to populate a bill template with account-specific details and produce a bill for each account.
- Observed behavior
- A lookup formula should fill the template for the selected account, and a macro can repeat the process for each account.
Arrange the source data with account numbers in the first column and one row per account. For the example below, name the data sheet Table and the bill template sheet Bill.
Build a Bill Template with a VLOOKUP Formula
Use an account number as the key to fill a bill with matching data from a table.
On the Table sheet, put account numbers in column A and amounts in column B, with headers in row 1 and data beginning in row 2.
On the Bill sheet, enter an account number in cell A2. Use the same data type as the account numbers on the Table sheet.
In the bill's amount cell, enter =VLOOKUP($A$2,Table!$A:$B,2,FALSE). The formula returns the amount for the account in A2.
Change Bill!A2 to another account number and confirm that the amount updates. Add lookup formulas for other fields, adjusting the source range and column index as needed.

Print Bills for Each Account with an Excel VBA Macro
After testing the lookup-based template, loop through the account numbers and print a bill for each row.
Create Account-Based Bills in WPS Spreadsheets
Use a lookup formula in a WPS Spreadsheets bill template to retrieve each account's amount, then duplicate or print the completed bills.
- 1. Open the workbook: Open WPS Spreadsheets and choose Open to select your Excel workbook.
- 2. Prepare the table and template: Name the source sheet Table and place account numbers in column A and amounts in column B. On a Bill sheet, enter an account number in A2.
- 3. Add the lookup: In the bill's amount cell, enter =VLOOKUP($A$2,Table!$A:$B,2,FALSE) and check that it returns the correct amount.
- 4. Produce the bills: Change Bill!A2 for each account and use File > Print to print each bill, or duplicate the template sheet and enter a different account number on each copy.

Frequently Asked Questions
Why does my VLOOKUP formula return #N/A?
Check that the account number in Bill!A2 exists in Table column A and that both values use the same data type. Remove unwanted spaces, then verify that the formula ends with FALSE for an exact match.
How can I retrieve more than the amount for each bill?
Add columns for fields such as customer name or address on the Table sheet. In the Bill sheet, add a VLOOKUP formula for each field, expanding the table range and changing the column index to match the field.
Can the macro create a separate sheet for each bill instead of printing?
Yes. The example macro uses wsBill.PrintOut; it would need to be modified to copy the Bill sheet and give each copy a unique, valid sheet name.
Will the lookup formula add up several rows for the same account?
No. VLOOKUP returns the first match. For a total, use a formula such as =SUMIF(Table!$A:$A,$A$2,Table!$B:$B), which adds amounts in column B for the account in A2.
Can I run the Excel VBA macro in WPS Spreadsheets?
VBA support depends on the WPS edition and configuration, and macro compatibility can vary. Check whether your installation offers a VBA editor and test the macro before relying on it; the lookup-based template can also be used without a macro.




