How to Sum Demand When Item Codes Match Combined Codes in Spreadsheet
Question details
Summing demand values from a table where item codes are grouped together in single cells separated by commas.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Consolidating and analyzing data where multiple item codes share the same demand row in a source table.
- Observed behavior
- The user needs to find individual item codes within combined comma-separated entries and sum their corresponding demand values without using VBA macros.
Ensure that your data is cleanly formatted and that the separator used in your combined codes (such as a comma followed by a space) is consistent across all rows.
Use SUMPRODUCT with ISNUMBER and SEARCH Formula
This robust formula safely identifies exact codes within comma-separated lists and sums their corresponding values, entirely avoiding the need for VBA.
To prevent false partial matches (for example, code 'A' incorrectly matching 'AB' or '1' matching '10'), we append the separator (a comma and space) to the beginning and end of both the search criteria and the lookup range. This guarantees the formula only counts distinct item codes.
Locate the cell containing your target individual item code (e.g., D2). Identify the range containing the combined codes in your source table (e.g., A2:A10) and the corresponding demand values (e.g., B2:B10).
Select the cell where you want the calculated total. Enter the following formula: =SUMPRODUCT(--(ISNUMBER(SEARCH(", "&D2&",", ", "&$A$2:$A$10&","))), $B$2:$B$10)
Press Enter to execute the formula. The formula evaluates each row, checks if the exact code exists in the combined string using the SEARCH function, and sums the matching demand values.
Click the bottom-right corner of the formula cell and drag the fill handle down to apply the formula to the remaining individual item codes in your summary table.

Split and Sum Using Power Query
For very large datasets or complex reporting, using Power Query to split the combined codes into new rows before summing is a more scalable and visual approach.
Efficiently Sum Complex Data with WPS Spreadsheet
WPS Spreadsheet offers powerful formula processing engines that handle complex array operations and wildcards seamlessly, allowing you to extract and sum data from combined cells effortlessly.
- 1. Open your workbook: Launch WPS Spreadsheet and open the file containing your item codes and demand tables.
- 2. Apply the calculation: Select your target cell and input the SUMPRODUCT formula provided in the solution.
- 3. Process the data: Press Enter to instantly calculate the total demand, and use the drag-fill tool to complete your summary table.

Frequently Asked Questions
How can I avoid false matches when summing combined item codes?
To prevent a code like '1' from matching '10', you must wrap your search criteria and your lookup text in delimiters. By searching for ", 1, " within ", "&Combined_Range&", ", you ensure that only the exact standalone code is identified and matched.
Why does my standard SUMIF wildcard formula return incorrect totals?
A standard SUMIF formula using wildcards (e.g., "*"&Code&"*") will blindly match sequences of text. If you search for 'A', it will also count rows containing 'AB' or 'CA', inflating your totals. Use the SUMPRODUCT and SEARCH method with padded commas to resolve this.
Is VBA absolutely necessary for splitting and summing comma-separated text?
No, VBA is not required. Modern spreadsheet array formulas (like SUMPRODUCT combined with ISNUMBER and SEARCH) or data manipulation tools like Power Query can dynamically handle comma-separated strings natively.




