VBA & Macro Problems

Create Multiple Bills in Excel Using Formulas and Macros

Amos GikundaAmos Gikunda Nov 20, 2026 868 views

Question details

Generate multiple bills from an Excel data table without manually copying each account's information.

Create Multiple Bills in Excel Using Formulas and Macros
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.
Before you start

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.

Solution 1Recommended

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.

1
Set up the source 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.

2
Add an account key

On the Bill sheet, enter an account number in cell A2. Use the same data type as the account numbers on the Table sheet.

3
Look up the amount

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.

4
Test the template

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.

Build a Bill Template with a VLOOKUP Formula
Multiple rows per account: VLOOKUP returns the first matching row. If an account has multiple line items, use a different approach for the line items or a summary formula such as SUMIF for totals.
Create bills in WPS Spreadsheets

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. 1. Open the workbook: Open WPS Spreadsheets and choose Open to select your Excel workbook.
  2. 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. 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. 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.
Populate bills from an account number using VLOOKUPOpen and edit Microsoft Excel XLSX workbooksUse a familiar spreadsheet interface to prepare and print billsCreate individual bill sheets from a reusable template
microsoft office alternative - wps office

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.