How to write a Countif then Sum?
I would like to write a formula that will sum a range if each cell meets a certain criteria. For example: Range A1:A20 = different prices. Range B1:B20 = Apples or Oranges. I need a single cell to compute the sum of Range A1:A20 if the cell next to it is either apple or orange.
Re: How to write a Countif then Sum?
Use 2 SUMIF() or use SUMPRODUCT():
Code:
=SUMIF(B1:B20,"Apple",A1:A20)+SUMIF(B1:B20,"Orange",A1:A20)
or
=SUMPRODUCT(((B1:B20="Apple")+(B1:B20="Orange"))*(A1:A20))