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.

This is the formula: =SUM(1/COUNTIF(C4:C26,C4:C

...I want to add 3 more cells, so I modify to this:

=SUM(1/COUNTIF(C4:C29,C4:C

The modified formula gives me a division error: #DIV/0!

The odd thing is there are values in all the cells.

Microsoft Excel

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.

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.

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

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.

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

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

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

Thank you, gentlemen!

maybe this is a behavior change in excel, due to it is not a documented way

try this instead

try this instead

```
=SUM(IF(FREQUENCY(MATCH(C4:C27,C4:C27,0),MATCH(C4:C27,C4:C27,0))>0,1))
```

Thanks for the formula, FarWest!

You are welcome.