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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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)
 
Upvote 0
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?
 
Upvote 0
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)
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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
Back
Top