Sum up cells based on the value yes/no

Karlbirger

Board Regular
Hi guys,

I have two columns, A and B. In column A the value can be either "Yes" or "No".
I have problems to engineer a formula that sum up all cells in column B where the equivalent cells in column A equals "Yes".
Is this possible to construct in Worksheet_SelectionChange and add to a specific cell so I dont have to update it manually to see the total value?

Thanks for the help.

Regards
KB

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try

=SUMIF(A:A,"Yes",B:B)

**** that was an easy code.

Big thumbs up VoG!

Thanks
KB

If I would like to add an extra cell in column C, e.g the value 2011 (the year of today), can I add this into the code

Code:
``=SUMIF(H:H;"Yes";AI:AI)``

in any way?

In other words: If the cell in column A says "Yes" and the cell in column C says "2011", then sum up the equivalent cells in column B.

Thanks in advance
KB

Try

=SUMPRODUCT(--(A1:A1000="Yes"),--(C1:C1000=2011),B1:B1000)

Cant really get that code to work. I wrote:

Code:
``=SUMPRODUCT(;(A1:A1000="Yes");(C1:C1000=2011);B1:B1000)``

I have tried this one too but it gives me an error:

Code:
``=SUMIFS(B:B;A:A;"Yes";C:C;"2011")``

Shouldnt SUMIFS be appropriate here?

Try

=SUMPRODUCT(--(A1:A1000="Yes");--(C1:C1000=2011);B1:B1000)

Works, but it returns "0", which it shouldn't. There are values in column B that have equivalent values of "Yes" and "2011".

Any ideas?

Last edited:
In column C are the values actually 2011 or are they dates formatted to show only the year?

My mistake, you are correct. The cells are formated to show only the year of a full date.

Replies
8
Views
128
Replies
4
Views
70
Replies
3
Views
186
Replies
7
Views
270
Replies
4
Views
222

Threads
1,203,462
Messages
6,055,565
Members
444,799
Latest member
CraigCrowhurst

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

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