Avatar of John Darby
John Darby
Flag for United States of America asked on

Excel formula for Counting Unique entries in column

I have a formula which I want to alter to include three more cells in a column, but when I change the formula, I get a division error:

This is the formula: =SUM(1/COUNTIF(C4:C26,C4:C26))
...I want to add 3 more cells, so I modify to this:
=SUM(1/COUNTIF(C4:C29,C4:C29))

The modified formula gives me a division error: #DIV/0!
The odd thing is there are values in all the cells.
Microsoft Excel

Avatar of undefined
Last Comment
FarWest

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Saurabh Singh Teotia

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Phillip Burton

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
John Darby

ASKER
Wow, Ctrl+Shift+Return did it; brief question: why does that work? :)
Phillip Burton

Because your formula is an "array formula", and that's how you have to end it.

If you highlight the cell, you will notice a pair of {} around it. That is the indication that it's an array formula.
Saurabh Singh Teotia

Ctrl+Shift+Enter...

Makes the formula array which means it checks each cell by one in your arrangement and give you an answer,,,

If you notice countif(rng,cell) is not an array formula and it's normally applied on one cell at a time but when you convert it an array it checks your each cell in data and then accordingly give you  an answer...

You can go to formula-->evaluate formula anytime to see how the formula is working...

Here is more definition of array formulas...

https://support.office.com/en-za/article/Guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
John Darby

ASKER
Thank you, gentlemen!
FarWest

maybe this is a behavior change in excel, due to it is not a documented way
try this instead
=SUM(IF(FREQUENCY(MATCH(C4:C27,C4:C27,0),MATCH(C4:C27,C4:C27,0))>0,1))

Open in new window

John Darby

ASKER
Thanks for the formula, FarWest!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
FarWest

You are welcome.