Counting the digits of a number in a range

S

stakar

I have a problem to solve
In a range of 5 cells there are unique numbers between 01 and 45. I
wanna count how many specific digits a time, they are in the range. The
digit that i wanna know it will be given by me.

Eg.
cell -> A1 B1 C1 D1 E1
NUM->01 05 15 14 44

The result must be ....
(it depends on what digit i wanna check each time, but for the
understanding of the issue i m giving all the results)

digit 0 -> 2 times (nums -> 01-05)
digit 1 -> 3 times (nums -> 01-15-14)
digit 4 -> 3 times (nums -> 14-44)
digit 5 -> 2 times (nums -> 05-15)

Is there any idea ??
Thanks in advance
 
K

Ken Wright

With your data in say A1:A5, and the digit you are counting in say cell D1, then
in any other cell you can use:-

=SUMPRODUCT(LEN(SUBSTITUTE(A1:A5,D1,"")))
 
K

Ken Wright

System deleted my note for some reason - Let's try again

With your data in say A1:A5, and the digit you are counting in say cell D1, then
in any other cell you can use:-

=SUMPRODUCT(LEN(SUBSTITUTE(A1:A5,D1,"")))
 
P

Peo Sjoblom

One way

=SUMPRODUCT(LEN(A2:E2)-LEN(SUBSTITUTE(A2:E2,G1,"")))

where G1 holds the digit you want to count
 
K

Ken Wright

Dohhhh!!! - I gave you the count of the digits left after the substitution,
which doesn't really help unless you know what it was BEFORE the substitution.

=SUMPRODUCT(LEN(A1:A5)-LEN(SUBSTITUTE(A1:A5,D1,"")))

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :)
----------------------------------------------------------------------------



Ken Wright said:
System deleted my note for some reason - Let's try again

With your data in say A1:A5, and the digit you are counting in say cell D1, then
in any other cell you can use:-

=SUMPRODUCT(LEN(SUBSTITUTE(A1:A5,D1,"")))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top