Function Problems

How to Sum Items by Name Across Multiple Rows in Excel

Tauseeq MagsiTauseeq Magsi Nov 10, 2026 868 views

Question details

Sum numeric values associated with specific item names across a nonstandard, multi-row layout without double-counting.

How to Sum Items by Name Across Multiple Rows in Excel
Product
Excel
Device & OS
not provided
Scenario
Calculating totals in a complex workbook layout where names and their corresponding numeric values are staggered across multiple non-adjacent rows and columns.
Observed behavior
Standard functions like SUM or SUMIF fail to accurately aggregate the data, often double-counting values when a name appears in multiple related rows.
Before you start

Carefully identify the exact dimensions of your numeric ranges and name ranges. Complex array formulas require perfectly matching row and column dimensions to avoid calculation errors.

Solution 1Recommended

Use SUM and MMULT for Dynamic Header-Based Matching

This is the most efficient method for multiplying matching columns by their header values using an array calculation.

The MMULT function returns the matrix product of two arrays. By converting true/false matches into 1s and 0s using a double unary operator (--), you can cross-reference multiple rows of names against a transposed header row of numeric values.

1
Set up the lookup value

Select an empty cell (e.g., I3) and type the name of the item you want to find the sum for.

2
Enter the MMULT formula

Click on your designated result cell and enter the formula: =SUM(MMULT(--($B$3:$F$12=$I3),TRANSPOSE($B$2:$F$2)))

3
Adjust the ranges

Modify $B$3:$F$12 to match the exact grid where your item names are located, and change $B$2:$F$2 to match the row containing the numeric values or headers.

4
Calculate the result

Press Enter to calculate. In older versions of Excel, you may need to press Ctrl+Shift+Enter to execute this as an array formula.

Use SUM and MMULT for Dynamic Header-Based Matching
Matrix Dimension Rule: Ensure the column count of your first array exactly matches the row count of your transposed second array, otherwise MMULT will return a #VALUE! error.
Efficient Data Calculation with WPS Office

Calculate Complex Multi-Row Data Easily with WPS Spreadsheet

WPS Spreadsheet provides robust support for advanced array formulas like SUMPRODUCT and MMULT, allowing you to seamlessly process nonstandard data layouts. It is a lightweight, full-featured alternative that completely supports standard Excel formulas.

  1. 1. Open the workbook: Launch WPS Spreadsheet and open your nonstandard layout data file.
  2. 2. Select your output cell: Click on the cell where you want the aggregated sum to be displayed.
  3. 3. Insert the array formula: Go to the Formula Bar and paste your chosen SUMPRODUCT or MMULT array formula. Use your mouse to drag and verify the highlighted reference ranges.
  4. 4. Apply and calculate: Press Enter to instantly process the data across multiple rows without double-counting.
Fully compatible with Microsoft Excel formats (.xlsx, .xls) and legacy array formulas.Built-in function helper makes it easier to select complex multi-row ranges.Lightweight and fast, effortlessly handling complex MMULT and matrix operations.Completely free to download with a familiar user interface.
QA img-9

Frequently Asked Questions

Why does my MMULT formula return a #VALUE! error?

This error typically occurs due to mismatched array dimensions. For the MMULT function to work, the number of columns in array1 must equal the number of rows in array2. Using the TRANSPOSE function on your header row usually resolves this.

Can I use the SUMIFS function instead of SUMPRODUCT?

Standard SUMIFS functions are designed for simple, parallel column-and-row tabular structures. When dealing with nonstandard layouts where criteria and sum ranges span across disconnected, multiple rows, advanced array functions like SUMPRODUCT or MMULT are required.

What does the double dash (--) mean in Excel formulas?

The double unary operator (--) coerces boolean values (TRUE or FALSE) generated by conditional tests into numeric values (1 or 0). This is required so mathematical functions like SUMPRODUCT and MMULT can successfully multiply the arrays.

Is there an easier way to handle nonstandard data layouts?

Yes. If possible, normalize your data into a flat table format where each row represents a single record with standardized columns. Once normalized, you can easily use basic PivotTables or SUMIFS to aggregate the data without complex array formulas.