How to find duplicate digits on Excel.

trident0911

New Member
Joined
Jul 12, 2022
Messages
1
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi Guys, I would like to know whether if its possible to identify the same 4 digits in Excel?

Example : Number 1234, to find other combinations of these four Digits like 1243, 1342, 4213 etc.

Data will also contain repeating numbers like 1113 and 2244.

Your solutions will be much appreciated, thanks in advance!

1657609095528.png
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
As per your explanation, it is just an idea to find the duplicates by summing up the cell values.

Example to find duplicate logic is

1234 (1+2+3+4 = 10)
4231 (4+2+3+1 = 10)
Likewise, you can find the duplicates.

To do the same,
Add the below formula in cell B1 then drag it down till the end of the data rows.

=SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))
 
Upvote 0
I haven't got time to complete the code but here is some code that will extact the 4 digits into an array, which is the way I would start. The next step would then be to loop down the column and do a comparison. Not necessarily that easy because of the requirement that they can be in any order:
VBA Code:
Sub test()
tt = 1234
Dim ta(1 To 4) As Integer
 For i = 1 To 4
   ta(i) = tt Mod 10
   tt = WorksheetFunction.RoundDown(tt / 10, 0)
  
 Next i
MsgBox (ta(1) & " " & ta(2) & " " & ta(3) & " " & ta(4))


End Sub
 
Upvote 0
As per your explanation, it is just an idea to find the duplicates by summing up the cell values.

Example to find duplicate logic is

1234 (1+2+3+4 = 10)
4231 (4+2+3+1 = 10)
Likewise, you can find the duplicates.

To do the same,
Add the below formula in cell B1 then drag it down till the end of the data rows.

=SUMPRODUCT(1*MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))
How about:
1234 & 1135? Same total (10) but not dupplicate
 
Upvote 0
Hi
Have a look to this code
VBA Code:
Sub testy()
    Dim Col As Collection
    a = Cells(1, 1).Resize(10)
    With CreateObject("scripting.dictionary")
        For i = 1 To 10
            Set AL = CreateObject("System.Collections.ArrayList")
            For ii = 1 To 4
                AL.Add Mid(a(i, 1), ii, 1)
            Next
            AL.Sort
            X = Join(AL.toarray, "")
            If Not .exists(X) Then
                .Add X, a(i, 1)
            Else
                .Item(X) = .Item(X) & "/" & a(i, 1)
            End If
            Set AL = Nothing
        Next
       For i = 0 To .Count - 1
       X = Split(.Items()(i), "/")
       Cells(1, i + 5).Resize(UBound(X) + 1) = Application.Transpose(X)
       Next
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,891
Members
449,058
Latest member
Guy Boot

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