Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SUMIF function: sum if cell contain specific name

Tags:

function

excel

I would like to run a function in Excel 2010 which has to:

  • check which cell in a specific range contains a name
  • if the previous task is true, sum the adjacent cell

Example:

In range B2:B227 there are some names, like Acura, Audi, BMW, Cadillac, etc. In range C2:C227 there are the number of cars those manufactures sold in 2012.

I want to calculate the sum of cars sold by certain manufacturers.

I was thinking about something similar, but it doesn't work. I think I made a mistake on the first step (recognize the names in cell B2:B227).

=SUMIF(B2:B227,OR("Audi","Acura","BMW","Cadillac"),D2:D227)

Thank you,

Gianluca

like image 871
Gianluca Avatar asked Apr 24 '13 09:04

Gianluca


People also ask

How do you sum if a cell contains specific text?

Sum if cell contains text If you are looking for an Excel formula to find cells containing specific text and sum the corresponding values in another column, use the SUMIF function. Where A2:A10 are the text values to check and B2:B10 are the numbers to sum. To sum with multiple criteria, use the SUMIFS function.

How do you sum cells with specific criteria?

If you want, you can apply the criteria to one range and sum the corresponding values in a different range. For example, the formula =SUMIF(B2:B5, "John", C2:C5) sums only the values in the range C2:C5, where the corresponding cells in the range B2:B5 equal "John."

Can Sumifs criteria reference a cell?

You can provide cell references as arguments of the SUMIFS function.

Does Sumifs work with text?

SUMIFS is a function to sum cells that meet multiple criteria. SUMIFS can be used to sum values when corresponding cells meet criteria based on dates, numbers, and text. SUMIFS supports logical operators (>,<,<>,=) and wildcards (*,?) for partial matching.


1 Answers

You can use SUMIF but as the result is an array (one sum for each criterion) you need to use SUM or SUMPRODUCT around the SUMIF to get the total, e.g.

=SUM(SUMIF(B2:B227,{"Audi","Acura","BMW","Cadillac"},D2:D227))

or list Audi, Acura etc in a range of cells e.g. K2:K5 and use this version

=SUMPRODUCT(SUMIF(B2:B227,K2:K5,D2:D227))

like image 149
barry houdini Avatar answered Oct 22 '22 14:10

barry houdini