For every cell value that contains string, sum another cell

litlmike

New Member
Joined
Jul 13, 2018
Messages
12
I am not sure the best way to describe this. I have a spreadsheet with the following headers:
Date; Ticker; Transaction Type; # of Shares; $ / Share; Cost

Under transaction type, the cell will contain "Buy" or "Sell". I would like to make two additional headers that are "Sum of Buy", "Sum of Sell". How do I create a formula that for every rows in Column C that contains "Buy" to add the grand total under "Sum of Buy"? Hope this makes sense.
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
9,595
Office Version
2019
Platform
Windows
Try sumif, the following formula will sum the amounts in column E for any rows that say Buy in column C

=SUMIF(C:C,"Buy",E:E)
 

litlmike

New Member
Joined
Jul 13, 2018
Messages
12
Try sumif, the following formula will sum the amounts in column E for any rows that say Buy in column C

=SUMIF(C:C,"Buy",E:E)
Thanks that worked beautifully!
...
Now that I am looking at it though, I forgot that for each time a C row has "Buy", I need to first find the product of the D cell multiplied by the E cell, then add all those products together. Is this possible?
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
9,595
Office Version
2019
Platform
Windows
You can do that with sumproduct, but it is not good with full columns. The formula below calculates rows 2 to 10, you can change this to whatever you need but try to keep it realistic based on the amount of rows that you have, or could have if it is variable.

=SUMPRODUCT(--(C2:C10,"Buy"),D2:D10,E2:E10)
 

Watch MrExcel Video

Forum statistics

Threads
1,099,571
Messages
5,469,467
Members
406,654
Latest member
MR_EXCEL_16

This Week's Hot Topics

Top