how to count different cells

scottlarock

Board Regular
Joined
Apr 10, 2009
Messages
102
Hello,
I am trying to find a formula that would count the number of different cells in column B from cells B4 to B500.

I would like to indicate the number of different cells in cells A4 to A500 (i.e: from 1 to ...200 if there are 200).

The goal is to count the number of projects, and the projects are repeated several times in column B.

Tons of thanks in advance for your help !!

Phil
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Firstly, I want to check that I understand your question.
You want to find how many distinct values are in a range of cells. I know how to do this manually (using VB) but you may be able to use several functions together.
Something that could help is frequency calculation (ie used in cumulative frequencies and other stuff). All you would need to do is get the number of frequencies collected by the function (and ignore the frequencies themselves for now).
Otherwise I'd write it like this:
Create something that you can do an IsIn() style content check on (ie string, array, db, whatever, I'm not so experienced with VB collections yet)
Iterate the range
If the cell doesn't exist, add it to the list

Then get the list size :)

Hope this helped, I will return if needed.
NF
 
Upvote 0
Hi Try:


=SUM(IF(FREQUENCY(IF(LEN(B4:B500)>0,MATCH(B4:B500,B4:B500,0),""), IF(LEN(B4:B500)>0,MATCH(B4:B500,B4:B500,0),""))>0,1))

Enter with Shift-Cntrl-Enter so it looks like

{=SUM(IF(FREQUENCY(IF(LEN(B4:B500)>0,MATCH(B4:B500,B4:B500,0),""), IF(LEN(B4:B500)>0,MATCH(B4:B500,B4:B500,0),""))>0,1))}
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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