To sum values where a cell contains specific text, you can use SUMIF. In the criteria, wrap the text in asterisks within SUMIF’s criteria: =SUMIF(A2:A10,”*Mobile*”,B2:B10). The * wildcard tells Excel to ignore whatever comes before or after the word, so it matches “Mobile Cover” and “Samsung Mobile” alike.
To sum values from cells where you have a specific text or a partial text, you need to use wildcard characters with SUMIF. In the criteria argument, you need to use an asterisk before and after the text using an ampersand, just like we have used in the following example to sum cells where you have the text “Mobile” in the “Product” column.

In this tutorial, we will learn to write this formula by using SUMIF.
Formula to Sum IF Cell Contains a Specific Text
- First, in cell C1, enter “=SUMIF(“.
- Next, refer to the range you need to check for the criteria.
- Now, in the criteria, enter an asterisk-criteria-asterisk (“*”&”Mobile”&”*”).
- Next, in the sum_range argument, refer to the quantity column.
- In the end, hit Enter to get the result.

=SUMIF(A2:A10,"*"&"Mobile"&"*",B2:B10)

The formula looks at each cell in the range A2:A10 and checks whether the word “Mobile” appears anywhere in each cell. The “*” wildcard character on both sides of “Mobile” tells Excel to ignore what comes before or after it, which makes it a partial text. Also, SUMIFS can be used if you have multiple conditions.
=SUMIFS(sum_range, criteria_range1, "*text*")
Sum IF a Cell Contains Partial Text using Case-Sensitive Match
If you want to sum values based on a case-sensitive search, use an array formula combining FIND, IF, and SUM. This formula requires a manual array setup to handle case-sensitive partial-text matches.
=SUM(IF(ISNUMBER(FIND("MOBILE", A2:A10)), B2:B10, 0))

Note: For this formula to work as an array formula in some versions of Excel, you need to enter it with Ctrl+Shift+Enter.
This formula sums values from column B, but only for rows in column A containing the exact word “MOBILE” in uppercase.
Here’s how it works: The formula goes through each cell in the range A2:A10 and uses the FIND function, which is case-sensitive, to look for the value “MOBILE”.
If FIND finds “MOBILE”, it returns a number indicating where “MOBILE” starts in the text. The ISNUMBER function checks if FIND returned a number (meaning “MOBILE” was found). If it did find “MOBILE”, the corresponding value from column B is included in the sum.
If “MOBILE” wasn’t found, or if it’s in a different case (like “Mobile” or “mobile”), it adds zero instead for that row. This way, the formula only adds up the numbers from column B where “MOBILE” exactly matches in column A.
Use Dynamic Functions to Sum Values on a Partial Text
Yes, you can use Excel’s dynamic array functions to sum based on partial text more dynamically and efficiently, especially in newer versions of Excel that support these features.
Let’s say column A contains product names, and column B contains corresponding sales figures. You want to sum all sales values where the product name contains “Mobile”:
=SUM(FILTER(B:B, ISNUMBER(SEARCH("Mobile", A:A))))

This formula sums up values from column B, but only for rows where the word “Mobile” is found in column A.
It searches for “Mobile” in each cell of column A and, if found, adds the corresponding value from column B in the total. If “Mobile” isn’t found in any cell, or if there’s an error, the formula returns 0.
But if no cells meet the criteria, FILTER will show an error, which you can handle with IFERROR:
=IFERROR(SUM(FILTER(B:B, ISNUMBER(SEARCH("Mobile", A:A)))),0)

Or you can use BYROW in combination with SEARCH.
=SUM(BYROW(A:A, LAMBDA(cell, IF(ISNUMBER(SEARCH("Mobile", cell)), INDEX(B:B, ROW(cell)), 0))))

This formula checks column A for the word “Mobile”. If the word “Mobile” is found in a row, the formula looks at the corresponding row in column B and takes that sales value. If the text “Mobile” is not found, it takes zero instead. Add up all the numbers that were picked from column B.
Use a Custom Function to SUM Values Based on a Partial Text
And if you’d like to use a custom function for this, here’s a VBA function that performs a case-insensitive sum based on a partial text match:

Function iSUMIFCONTAINS(searchRange As Range, searchText As String, sumRange As Range) As Double Dim cell As Range Dim sumResult As Double ' Initialize the result variable. sumResult = 0 ' Check if both ranges are of the same size If searchRange.Rows.Count <> sumRange.Rows.Count Or searchRange.Columns.Count <> sumRange.Columns.Count Then iSUMIFCONTAINS = CVErr(xlErrRef) Exit Function End If ' Loop through all cells in the searchRange For Each cell In searchRange If InStr(1, cell.Value, searchText, vbTextCompare) > 0 Then ' If searchText is found, add the corresponding value from sumRange sumResult = sumResult + sumRange.Cells(cell.Row - searchRange.Row + 1, cell.Column - searchRange.Column + 1).Value End If Next cell ' Return the result iSUMIFCONTAINS = sumResult End Function
Press ALT + F11 to open the VBA editor. In the VBA editor, right-click on any objects in your project explorer. Then, choose Insert > Module. This action creates a new module. Paste it into the newly created module.
Now, you can use this new function: iSUMIFCONTAINS
=iSUMIFCONTAINS(A2:A10,"Mobile",B2:B10)
And if you want to do a sum for partial text based on case sensitivity:
Function iSUMIFCONTAINS(searchRange As Range, searchText As String, sumRange As Range, Optional caseSensitive As Boolean = False) As Double Dim cell As Range Dim sumResult As Double Dim compareMode As Integer ' Determine comparison mode based on case sensitivity option If caseSensitive Then compareMode = vbBinaryCompare ' Case-sensitive Else compareMode = vbTextCompare ' Case-insensitive End If ' Initialize the result variable. sumResult = 0 ' Check if both ranges are of the same size If searchRange.Rows.Count <> sumRange.Rows.Count Or searchRange.Columns.Count <> sumRange.Columns.Count Then iSUMIFCONTAINS = CVErr(xlErrRef) Exit Function End If ' Loop through all cells in the searchRange For Each cell In searchRange If InStr(1, cell.Value, searchText, compareMode) > 0 Then ' If searchText is found, add the corresponding value from sumRange sumResult = sumResult + sumRange.Cells(cell.Row - searchRange.Row + 1, cell.Column - searchRange.Column + 1).Value End If Next cell ' Return the result iSUMIFCONTAINS = sumResult End Function
=iSUMIFCONTAINS(A2:A10,"MOBILE",B2:B10,TRUE)
Related Formulas
- Sum Greater than Values using SUMIF
- Sum Not Equal Values (SUMIFS) in Excel
- SUMIF / SUMIFS with an OR Logic in Excel
- SUMIF with Wildcard Characters in Excel
- SUMIFS Date Range (Sum Values Between Two Dates Array)
- Combine VLOOKUP with SUMIF
- Sum Values Based on Year (SUMIF Year)
- SUMIF By Date (Sum Values Based on a Date)
-
Back to the List of Excel Formulas
This post really helped me understand how to use the SUMIF function with partial text
This post was incredibly helpful! I often struggle with functions in Excel, but your clear explanation of the SUMIF function with partial text made it so easy to follow. I can’t wait to try it out in my own spreadsheets. Thank you for sharing!