Formula to search 3 or more criteria, then count text

Kthom019

New Member
Joined
May 16, 2017
Messages
46
I need help putting together a formula that will do the following:
1. Search for company name "ABC" in column A, then
2. Search for product category "Books" in column B, (there a 6 different product categories that I will be searching for), then
3. Search for product distribution type "truck" in column C, then
4. If the above criteria are met then, count the "alphanumeric codes" in column D
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Company Name[/TD]
[TD]Category[/TD]
[TD]Distribution Type[/TD]
[TD]Codes[/TD]
[/TR]
[TR]
[TD]Bookran[/TD]
[TD]Book[/TD]
[TD]Truck[/TD]
[TD][TABLE="width: 91"]
<colgroup><col></colgroup><tbody>[TR]
[TD]AP6802400[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]Telstar[/TD]
[TD]Book[/TD]
[TD]Cart[/TD]
[TD][TABLE="width: 91"]
<tbody>[TR]
[TD]IM1338917[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]Major[/TD]
[TD]Pen[/TD]
[TD]Gate[/TD]
[TD]CH3117672[/TD]
[/TR]
[TR]
[TD]Bookran[/TD]
[TD]Book[/TD]
[TD]Truck[/TD]
[TD]CS6540201[/TD]
[/TR]
[TR]
[TD]Major[/TD]
[TD]Pen[/TD]
[TD]Gate[/TD]
[TD]TN9358217[/TD]
[/TR]
</tbody>[/TABLE]

I hope the information above is sufficient, I am creating a reporting sheet to pull data from this detailed sheet with thousands of records.

Please assist soonest; thanks.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Welcome to the board. Try:
Code:
=SUMPRODUCT(--($A$1:$A$500="ABC"),--($B$1:$B$500="Books"),--($C$1:$C$500="truck"),$D$1:$D$500)
 
Upvote 0
=COUNTIFS($A:$A,$F1,$B:$B,$G1,$C:$C,$H1,$D:$D,"?*")

where F1 houses a company of interet like Major, G1 a product category like Book, and H1 a distribution type like Truck.
 
Upvote 0
I am using the sumproduct function:

Column A: Company
Column B: Category
SUMPRODUCT(('workbook'!A:A=A2)*('workbook'!B:B=B2)*('Workbook'!C:C="*truck*")*'workbook'!D:D)
This function returns "VALUE" error.
I am obviously using the wrong formula or missing something.
 
Upvote 0
Use COUNTIFS which is faster: See post #3 .

If you can't, try:

=SUMPRODUCT(--($A:$A=$F1),--($B:$B=$G1),--($C:$C=$H1),--ISNUMBER(SEARCH("?*",$D:$D))

Try to avoid whole column references in a SumProduct formula for reasons of efficiency.
 
Upvote 0
@Aladin Akuyrek as a side, I should use COUNTIFs more than SUMPRODUCT as aware it's faster, but with COUNTIFs is using entire column slower than SUMPRODUCT with defined range?
 
Upvote 0
@Aladin Akuyrek as a side, I should use COUNTIFs more than SUMPRODUCT as aware it's faster, but with COUNTIFs is using entire column slower than SUMPRODUCT with defined range?

1. COUNTIFS(A2:A1000,"x",B2:B1000,"y",C2:C1000,"z")

2. SUMPRODUCT(--(A2:A1000="x"),--(B2:B1000="y"),--(C2:C1000="z"))

Using dynamic named ranges, number of records sufficiently large...

3. COUNTIFS(Arange,"x",Brange,"y",Crange,"z")

4. SUMPRODUCT(--(Arange="x"),--(Brange="y"),--(Crange="z"))

5. COUNTIFS(A:A,"x",B:B,"y",C:C,"z")

6. SUMPRODUCT(--(A1:An="x"),--(B1:Bn="y"),--(C1:Cn="z"))

1 and 3 will be faster than their equivalents, i.e. 2 and 4.

If n of [6] is not larger than a limit, it will be faster than [5]. I'm not sure what that n would be.
 
Upvote 0
I learnt about double unary converting TRUE and FALSE into 1 and 0, so intuitively SUMPRODUCT for requirements like this made more sense, but will use COUNTIFs more often, especially if it's faster.

Thank you @Aladin Akyurek for suggesting
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,022
Latest member
RobertV1609

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