Sumproduct Question

andy3816

Board Regular
Joined
Mar 22, 2005
Messages
135
I have a list of data and use sumproduct to return me various data based on fixed criteria.
I have now been asked to do the same thing but looking for a bunch of text strings that are contained in cell.

Is there a way to use someproduct to return a 1 in an array position based on whether a cell contains one of many text strings

something like

=someproduct(--(A1:A25="2011"),--(B1:B25contains(Text1, or text 2 or text 3)))

I can do this with multiple someproducts however the formula gets too long as there are 20 text variables I need to search for individually it would be great if I could use an OR and get it all into one.


Any help would be greatly appreciated
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Excel Workbook
ABCDE
1222
2Text1Text2
3
4
52010Text1
62011Text1
72011Text2
82011Text3
9
1a
Excel 2003
Cell Formulas
RangeFormula
B1=SUMPRODUCT(--(ISNUMBER(MATCH($B$5:$B$100,{"Text1","Text2"},0))),--($A$5:$A$100="2011"))
C1=SUMPRODUCT(--(ISNUMBER(MATCH($B$5:$B$100,D2:E2,0))),--($A$5:$A$100="2011"))
D1=SUMPRODUCT(--(($B$5:$B$100=D2)+($B$5:$B$100=D2)),--($A$5:$A$100="2011"))




N.B.
- consistent with your information the example entered the 2010 and 2011 as text

- edit the data ranges and criteria range as required

- the "+" with the formula in D1 is equivalent to "or"
 
Upvote 0
Thanks I did play around with Match but thought it needed an exact match.

Will Match work on part of a string

meaning if the contents of the cell A1 is TEXT1ABC
will Match (Text1,A1,0) return true?

?
 
Upvote 0
Thanks I did play around with Match but thought it needed an exact match.

Will Match work on part of a string

meaning if the contents of the cell A1 is TEXT1ABC
will Match (Text1,A1,0) return true?

?
If I understand what you want...

Use cells to hold the criteria:
  • D2 = 2011
The text strings to match must be entered in a horizontal range of cells:
  • E2 = text1
  • F2 = text2
  • G2 = text3
Then:

=SUMPRODUCT((A2:A10=D2)*(ISNUMBER(SEARCH(E2:G2,B2:B10))))

I notice in your top post you have:

=someproduct(--(A1:A25="2011")
When you quote numbers like that Excel evaluates them as TEXT not numbers.
 
Upvote 0
Thanks for your help, and yes users enter years as text not numbers...strange but true, go figure!!!!
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,706
Members
452,939
Latest member
WCrawford

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