With the help of SUMIF Function, we can also add cells that contain specific or partial text and even if the cells contain numbers and text altogether, they can also be added.
Let’s have a look on how is it done with a slight change in the formula
Using SUMIF if cells contain specific text
Figure 1. Example 1
Formula for specific text:
This is a grocery list with a range that contains specific repeated text. In order to add the sum range based on a specific text criteria, we need to:
- Take a separate column E for the criteria and F for the total quantity.
- Write down the specific criteria in E9 and E10.
- Use SUMIF formula in cell F9 with A3:A10 as range, “Fruit” as criteria instead of E9 and C3:C10 as sum_range.
- Press Enter to get the total quantity of fruit.
- Repeat the same with vegetable criteria to get the amount of total vegetables.
Using SUMIF if cells contain partial text
Figure 2. Example 2
Formula for partial text:
In this example, we need to use SUMIF function for a partial text in the range as we want to know the total number of cars sold in various countries.
- Take column D for the brand of cars as criteria and column E for the total quantity of cars sold.
- Use SUMIF Formula in E8 with Column A as range and Column B as sum_range whereas criteria D8 will be mentioned with wildcards.
(“*”& on both sides of the criteria D8 is known as wildcards)
- Enter the formula and drag it down to E11 and Excel will automatically calculate the quantities for other criteria’s.
Using SUMIF if cells contain text and numbers
Figure 3. Example 3
Formula for text and numbers:
We need to find the total price of all the shirts and pants in the given example by taking “Shirts” as one specific criteria with different numbers. Steps to follow are:
- Take column D and write down the specific words “Shirts” and “Pants” that are used with other words and figures in range.
- Take Column E for calculation of total price of all the shirts and pants in range.
- Use formula
=SUMIF(A3:A10,”*Shirts*”,B3:B10)in E3 and Enter.
- Use the same formula in E4 by only replacing the word “Shirts” with “Pants”.
- We can also use
=SUMIF(A3:A10,"*"&D3&"*",B3:B10)in E3 and drag it to E4 and we’ll get the same results.
(The second formula given in this example is the same one that is used in example # 2.It can be used in both cases)
Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.