Sumproduct with Partial Text

jlkirk

Active Member
Joined
May 6, 2002
Messages
328
Office Version
  1. 365
Very simple example. Need to total B2:B6 when C2:C6 contains the word "jeff". When I include additional words in any cell with a date month of January in addition to "jeff", the formula ignores the figure in related cell in B2:B6; when I include in the formula "*jeff*", the formula ignores all of the cells in B2:B6 where the adjacent cells in C2:C6 include "jeff"

The formula in B8 is "=SUMPRODUCT(B2:B6,(MONTH(A2:A6)=MONTH($A$1))*(C2:C6="jeff"))"

Any help?
Column A Column B Column C
1/1/2000
1/2/2024​
$100​
jeff
2/5/2024​
$234​
kathy
3/10/2024​
$466​
jon
12/20/2023​
$677​
jeff
1/15/2024​
$899​
Bill Jake Caroline Debby jeff
$100​
Sum B2:B6 when C2:C6 contains the word "jeff" (Should be $999)
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Sanjay,
I have one more "request" or "issue". A very simple solution I would think: please see below. I am trying to use the sumproduct formula you gave me for just the month of January and the year of 2024 for the following, but I get a zero. My formula (in C2) is "=SUMPRODUCT(B2:B15,MONTH(A2:A15)=MONTH(A1)*YEAR(A2:A15)=YEAR(A1))"

Column A Column B Column C
1/1/2024
1/2/2024​
$ -
0​
1/2/2024​
$ -
1/2/2024​
$ -
1/2/2024​
$ -
1/2/2024​
$ -
1/10/2024​
$ 70,000.00
1/10/2024​
$ 15,000.00
1/11/2024​
$ -
1/11/2024​
$ -
1/11/2024​
$ -
1/11/2024​
$ -
1/11/2024​
$ -
1/11/2024​
$ -
1/11/2024​
$ -
 
Upvote 0
Adjust your formula to this:
VBA Code:
=SUMPRODUCT(B2:B15 * (MONTH(A2:A15)=MONTH(A1)) * (YEAR(A2:A15)=YEAR(A1)))
The placement of the brackets around each criteria before applying the multiplication is important.
Note: for consistency I have also swapped out the comma after the B2:B15 for a "*"
 
Upvote 1
Adjust your formula to this:
VBA Code:
=SUMPRODUCT(B2:B15 * (MONTH(A2:A15)=MONTH(A1)) * (YEAR(A2:A15)=YEAR(A1)))
The placement of the brackets around each criteria before applying the multiplication is important.
Note: for consistency I have also swapped out the comma after the B2:B15 for a "*"
Yes, I see. Thanks again for all of your help.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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