Match Text with Leading Zeros Using SUMPRODUCT in Excel
Question details
Sum values only when an identifier matches the complete text, including leading zeros.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains identifiers such as 0055, 00055, and 0055A alongside values to sum.
- Observed behavior
- SUMIF or SUMIFS criteria can produce unexpected matches when numeric-looking text is interpreted as a number.
Check that the identifiers are stored as text, not merely displayed with leading zeros by a number format. Ensure the criteria and sum ranges cover the same rows and that the sum range contains numbers.
Use SUMPRODUCT to Compare the Complete Text
Use a direct text comparison when leading zeros distinguish one identifier from another.
Select the identifier cells in column A and check their values in the formula bar. Format new entries as Text using Home > Number Format before entering identifiers with leading zeros.
Select an empty cell and enter =SUMPRODUCT((A2:A10="0055")*B2:B10). Adjust both ranges to cover the same rows in your worksheet.
Press Enter. The formula sums the values in column B for rows where column A contains the text 0055, excluding 00055 and 0055A.

Match Identifiers with Leading Zeros in WPS Spreadsheets
Use SUMPRODUCT in WPS Spreadsheets to compare complete text identifiers and sum their corresponding values.
- 1. Open the spreadsheet: Open WPS Spreadsheets and use Open to select your workbook.
- 2. Check the identifiers: Select the identifier cells and check their values in the formula bar. Set new identifier cells to Text before entering values with leading zeros.
- 3. Enter SUMPRODUCT: Select an empty cell and enter =SUMPRODUCT((A2:A10="0055")*B2:B10), replacing the ranges with your identifier and numeric value ranges.
- 4. Review the sum: Press Enter and check that only rows containing the text 0055 contribute to the result.

Frequently Asked Questions
Can I use a cell as the identifier instead of typing 0055 in the formula?
Yes. If D2 contains the text identifier, enter =SUMPRODUCT((A2:A10=D2)*B2:B10). Store D2 and the identifiers in column A consistently as text.
Why did my leading zeros disappear?
The spreadsheet may have interpreted the entry as a number. Set the cells to Text before re-entering the identifiers, or type an apostrophe before an entry, such as '0055.
Does SUMIF always match 0055A when the criterion is 0055?
No. A plain criterion does not ordinarily match the extra letter in 0055A. Check for wildcard characters in the criterion and for numeric-looking text that may be interpreted as a number.
Why does SUMPRODUCT return an error?
Check that the identifier and sum ranges have the same dimensions. With the multiplication formula shown here, also check the sum range for text or error values.




