Is this formula the best option?

pawebb

Board Regular
Joined
Aug 10, 2007
Messages
136
I tried to create a pivot table to get my answer but couldn't figure out a clean way to do it. So I can up with the formula in the example. I wanted to see if there is a more efficient way to go about it. I need to count the number of times a store grade appears under a class.
Book1
ABCDE
1260_6537PROMOTIONAL260_6553SHORTLEATHER260_6567SUEDE262_6474FAUXFUR/PLUSH
2121212
3121210
41366
58888
6111210
711119
8121010
9121212
105455
11Classes
12StoreGrades260_6537PROMOTIONAL260_6553SHORTLEATHER260_6567SUEDE262_6474FAUXFUR/PLUSH
1311000
1420000
1530100
1640100
1751011
1860011
1970000
2081111
2190010
22100130
23112100
24124420
Sheet1


Thanks...
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try this in cell B13 and copy across all the other cells:
Code:
=SUMPRODUCT(--(B$2:B$10=$A13),--(B$2:B$10<>""))
 
Upvote 0
Try this in cell B13 and copy across all the other cells:
Code:
=SUMPRODUCT(--(B$2:B$10=$A13),--(B$2:B$10<>""))

It works great but is there a benefit to either way?
 
Upvote 0
I’m not entirely sure to be honest. I personally prefer to avoid using array formulas wherever possible because I find them less obvious to correct. However, there are times when they are the only/best solution. For your basic counting or summing exercises, I usually side with SUMPRODUCT because it is very versatile and generally quite clear to understand what you are trying to do when looking at it.
 
Upvote 0
It works great but is there a benefit to either way?

Generally speaking, NON array formulas perform faster than array formulas (CTRL + SHIFT + ENTER)

Plus, it's easy to forget to use CTRL + SHIFT + ENTER. If you've had the array formula working for a while, and need to make an adjustment to it, you might forget that it's an array formula and begin wondering why it doesn't work anymore...
 
Upvote 0
Hi

In your example you could also use in B13, copy down and accross:

=COUNTIF(B$2:B$10,$A13)

Hope this helps
PGC
 
Upvote 0
B3, copy across and down:

=COUNTIF(B$2:B$10,$A13)

Some remarks:

{=COUNT(IF(B$2:B$10=$A13,B$2:B$10))}

is expensive and not needed for a single condition.

The above applies to:

=SUMPRODUCT(--(B$2:B$10=$A13),--(B$2:B$10<>""))

Also, if one understands the "array formulas", SumProduct formulas are mutatis mutandis in the closure of that understanding. The reverse is also true.

BTW, the COUNTIF formula is faster than the others.
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

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