How to Sum Invoice Line Items and Match to a Summary Sheet in Excel
Question details
The user needs a method to total sales rows corresponding to specific invoices from a sales worksheet and return the aggregated subtotal to a separate summary sheet.

- Product
- Spreadsheets
- Device & OS
- not provided
- Scenario
- Consolidating invoice data across multiple worksheets where detailed line items are recorded separately from the main invoice summary.
- Observed behavior
- The goal state is an automated summary sheet that accurately matches an invoice number to its detailed sales rows and outputs the total sum.
Verify that your summary sheet and your detailed sales worksheet are contained within the same workbook, and ensure that the invoice numbers in both sheets are formatted identically (either both as text or both as numbers).
Use the SUMIF Function to Match and Total Invoice Items
The SUMIF function is the most efficient method to conditionally sum values from a detailed data sheet based on a specific criteria, such as an invoice number.
The SUMIF function evaluates a specified range for a certain condition and sums the corresponding values in another range. This prevents the need to manually add rows together.
Open your summary worksheet (e.g., SalesSummary) and select the cell where you want the first subtotal to appear, such as cell D2.
Type the formula =SUMIF(Sales!B:B, B2, Sales!G:G) into the cell. In this formula, 'Sales!B:B' represents the column of invoice numbers in your detailed sheet, 'B2' is the invoice number you want to match on your summary sheet, and 'Sales!G:G' contains the monetary values to add up.
Press Enter to calculate the first total. Click on the cell again, grab the small square fill handle at the bottom-right corner, and drag it down the column to apply the formula to the rest of your invoices.

Create a Pivot Table to Summarize All Invoices Simultaneously
If you have a large dataset and need to generate a summary sheet from scratch, a Pivot Table does this effortlessly without complex formulas.
Easily Sum Invoice Data with WPS Spreadsheet
WPS Office offers a highly compatible and intuitive Spreadsheet application that effortlessly handles advanced formulas like SUMIF. Whether you are generating complex pivot tables or consolidating daily sales data, WPS helps you organize your finances seamlessly.
- 1. Open your workbook: Launch WPS Spreadsheet and open the file containing your invoice data and summary sheet.
- 2. Select the summary cell: Click on the cell in your Summary sheet where the total should be displayed.
- 3. Insert the SUMIF function: Type =SUMIF( or use the 'Insert Function' tool from the Formulas tab to find it.
- 4. Define your ranges: Highlight your criteria range, click the lookup value, highlight the sum range, and press Enter.
- 5. Fill down: Drag the fill handle downwards to automatically calculate the totals for the remaining invoices.

Frequently Asked Questions
Why is my SUMIF formula returning a zero when there is data?
This usually happens if the invoice numbers in your summary sheet do not exactly match the data types in your sales sheet. For example, one column might be formatted as 'Text' while the other is formatted as a 'Number'. Ensure both columns share the same data format.
Can I sum invoice line items based on multiple criteria?
Yes. If you need to match multiple conditions, such as summing line items for a specific invoice number and a specific date, you should use the SUMIFS function instead of SUMIF. SUMIFS allows you to define multiple criteria ranges.
How do I fix the #NAME? error in my sum formula?
The #NAME? error occurs if the function name is misspelled or if there is a typo in the sheet name referenced in your formula (for instance, typing 'Sale!B:B' instead of the actual sheet name 'Sales!B:B'). Double-check your spelling and syntax.




