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.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
14,468
Office Version
  1. 365
Platform
  1. 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
14,468
Office Version
  1. 365
Platform
  1. 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)
 

Forum statistics

Threads
1,147,498
Messages
5,741,504
Members
423,663
Latest member
kaveh87rsh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top