# For every cell value that contains string, sum another cell

#### litlmike

##### New Member
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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

#### jasonb75

##### Well-known Member
Try sumif, the following formula will sum the amounts in column E for any rows that say Buy in column C

#### litlmike

##### New Member
Try sumif, the following formula will sum the amounts in column E for any rows that say Buy in column C

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
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.

#### litlmike

##### New Member
Thanks!

Replies
3
Views
544
Replies
2
Views
278
Replies
2
Views
685
Replies
0
Views
498
Replies
1
Views
153

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,152,115
Messages
5,768,205
Members
425,459
Latest member
Danniey

### 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.

### Which adblocker are you using?

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

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