countifs return values range

sx200apul

New Member
Joined
Sep 17, 2018
Messages
5
=SUM(COUNTIFS(D5:D15,"Mountain Blue",A5:A15,"*"&{1,2,3,4,5,6,7,8,9}&"xWindow*")*{1,2,3,4,5,6,7,8,9})

Counting window colours from Accessories Colour column.

this works fine if its 1-9 in the Extras … but when its 10+ the result is wrong.
What is the best way to make {1,2,3,4,5,6,7,8,9} … 1-99

Below:
Left 2 columns data, right 2 are results using above


[TABLE="class: grid, width: 500, align: left"]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]Extras[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Accessories Colour[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][TABLE="width: 352"]
[TR="class: grid"]
[TD="width: 352, colspan: 2"]Windows[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]1x30003150, 3x25002770, 2xMotor, 1xPAD, 3xInso[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Slate Grey[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][TABLE="width: 180"]
[TR="class: grid"]
[TD]Heritage Red[/TD]
[/TR]
[/TABLE]
[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]1x25005100, 1xMotor, 1xPAD[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Slate Grey[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][TABLE="width: 180"]
[TR="class: grid"]
[TD="width: 180"]Mist Green[/TD]
[/TR]
[/TABLE]
[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]2x25002770, 1xPAD, 1 xWindow[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Slate Grey[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][TABLE="width: 180"]
[TR="class: grid"]
[TD="width: 180"]Mountain Blue[/TD]
[/TR]
[/TABLE]
[/TD]
[TD]3[/TD]
[TD][TABLE="width: 131"]
[TR]
[TD="class: xl67, width: 131"]Result should be 13[/TD]
[/TR]
[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]1x30003150, 2x25002770, 9xWindow[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Smooth Cream[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][TABLE="width: 180"]
[TR="class: grid"]
[TD="width: 180"]Slate Grey[/TD]
[/TR]
[/TABLE]
[/TD]
[TD]5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]2x25002770, 4xWindow[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Slate Grey[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][TABLE="width: 180"]
[TR="class: grid"]
[TD="width: 180"]Smooth Cream[/TD]
[/TR]
[/TABLE]
[/TD]
[TD]10[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]2x25002770, 12xWindow[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Mountain Blue[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][TABLE="width: 180"]
[TR="class: grid"]
[TD="width: 180"]TOTAL[/TD]
[/TR]
[/TABLE]
[/TD]
[TD]19[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]2x25002770, 1xWindow[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Slate Grey[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]2xInso, 6xSideOB, 4xGableOB[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Mist Green[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]1x25002770, 1xPAD, 1xWindow[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Smooth Cream[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]1x25002770, 1xPAD, 1xWindow, 1xInso[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Heritage Red[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 309"]
[TR="class: grid"]
[TD="width: 309"]1xWindow, 1xSideOB, 2xGableOB[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][TABLE="width: 125"]
[TR="class: grid"]
[TD="width: 125"]Mountain Blue[/TD]
[/TR]
[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[/TABLE]
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
ROW(INDIRECT("1:99") will make an array {1,2,3...99}

=SUM(COUNTIFS(D5:D15,"Mountain Blue",A5:A15,"*"&ROW(INDIRECT("1:99")&"xWindow*")*ROW(INDIRECT("1:99"))

But then 12xWindow will be counted twice as 2xWindow and 12xWindow
I don't know how to get around that. I'm sure someone clever will figure it out.
 
Upvote 0
If each entry in the EXTRAS column began with a space character, then this would work...

=SUM(COUNTIFS(D5:D15,"Mountain Blue",A5:A15,"* " & ROW(INDIRECT("1:99")&"xWindow*")*ROW(INDIRECT("1:99"))
 
Last edited:
Upvote 0
If each entry in the EXTRAS column began with a space character, then this would work...

=SUM(COUNTIFS(D5:D15,"Mountain Blue",A5:A15,"* " & ROW(INDIRECT("1:99")&"xWindow*")*ROW(INDIRECT("1:99"))

I tried to apply this but Excel rejected it..
see below.. to my sheet as above..
=SUM(COUNTIFS(B5:B15,"Mountain Blue",A5:A15,"* " & ROW(INDIRECT("1:99")&"xWindow*")*ROW(INDIRECT("1:99"))

Just gave an Excel error popup, like Excel couldn't read it.. no result at all..

Any ideas?
 
Upvote 0
=SUM(COUNTIFS(B5:B15,"Mountain Blue",A5:A15,"* " & ROW(INDIRECT("1:99"))&"xWindow*")*ROW(INDIRECT("1:99")))
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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