Count Repeat Numbers

ststern45

Well-known Member
Joined
Sep 17, 2005
Messages
961
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hi everyone,

I have 2 cell ranges and would like to calculate how many digits repeated.

For example,
Cells (1st range of numbers)
A1 = 0
B1 = 5
C1 = 4
D1 = 6
E1 = 7
F1 = 7

Cells (2nd range of numbers)

A2 = 0
B2= 4
C2 = 8
D2 = 6
E2 = 4
F2 = 4

So there are a total of 3 digits that repeated
0, 6, and 4

In addition, only count the value once.

For example,
1st range of digits
0 - 1 - 4 - 7 - 9 - 9

2nd range of digits
0 - 5 - 0 - 9 - 9 - 8

In the above example there are 2 digits that repeat 0 & 9. But the 9 appears twice in both ranges but I would only want the 9 counted once.

Thank you in advance
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You want to use a COUNTIF function and combine that with a MIN function

=COUNTIF($A$1:$F$2,4) ... this one counts the number of 4s in the range. Replace 4 with whatever number you are looking for.
=MIN(COUNTIF($A$1:$F$2,4),1) ... this one returns 0 if 4 is not present and 1 if it is, regardless of how many 4s are in the range
 
Upvote 0
In B5 then copied across till blank cell is seen.
Excel Formula:
=IFERROR(INDEX($A$1:$F$1,AGGREGATE(15,6,COLUMN($A$1:$F$1)/((COUNTIF($A$2:$F$2,$A$1:$F$1)>0)*(COUNTIF($A$5:$A5,$A$1:$F$1)=0)),COLUMNS($B5:B5))),"")
A5 should be blank.
0​
5​
4​
6​
7​
7​
0​
4​
8​
6​
4​
4​
B5C5D5E5F5
0​
4​
6​
 
Upvote 0
Need a helper column in A3
A3: =IF(SUMPRODUCT(--($A$2:A2=A2))=1,IF(COUNTIFS($A$1:$F$1,A2)>1,1,COUNTIFS($A$1:$F$1,A2)),"")
G3: =SUM(A3:F3)



Bonus for excel 365 users requires no helper:
=SUMPRODUCT(--(COUNTIFS(A1:F1,UNIQUE(A2:F2,1))>0))
 

Attachments

  • 1670757056224.png
    1670757056224.png
    11 KB · Views: 8
Upvote 0
To calculate directly try this

22 12 11.xlsm
ABCDEFGH
10147992
2050998
Repeats
Cell Formulas
RangeFormula
H1H1=SUMPRODUCT(--(MATCH(A1:F1,A1:F1,0)=COLUMN(A1:F1)-COLUMN(A1)+1),--(COUNTIF(A2:F2,A1:F1)>0))
 
Upvote 0
Thank you everyone for all your help. Peter your formula worked.
I did not try the other suggestions.
Everyone is so amazing here at MrExcel.
Thank you, Thank you!!
 
Upvote 0
You're welcome. Glad we could help. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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