Character / Number Sequence

RRatajczyk

New Member
Joined
May 16, 2018
Messages
22
Please Help!

I am looking for a formula that will identify/detect when a part number is identical (a match) in a long list of part numbers and where it is different in the sequence by one character or number. i.e. ABC123456 vs ABC123465

the result would be "True" where this occurs

In other words the part numbers are identical with the exception of one of the characters or numbers is out of sequence (= TRUE)

and the whole long list of part numbers is being evaluated / compared
 
Last edited by a moderator:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
where it is different in the sequence by one character or number.
You mean they contain exactly the same characters, and an adjacent pair of characters is transposed? That would be two characters that differ.
 
Upvote 0
somehow all the part numbers in a list would have to be compared against each other to determine 1) the characters / numbers match 2) two characters or numbers are transposed
 
Upvote 0
somehow all the part numbers in a list would have to be compared against each other to determine 1) they match. 2) two characters or numbers are transposed
 
Upvote 0
Code:
Function Transpositions(sInp As String) As String()
  Dim i As Long
  ReDim asout(1 To Len(sInp)) As String
  
  asout(1) = sInp
  For i = 2 To Len(sInp) - 1
    asout(i) = Left(sInp, i - 1) & Mid(sInp, i + 1, 1) & Mid(sInp, i, 1) & Mid(sInp, i + 2)
  Next i
  
  Transpositions = asout
End Function

A​
B​
C​
1​
P/N
Matches
2​
ABC123457
1​
B1: {=SUM(COUNTIF($A$6:$A$10, Transpositions(A1)))}
3​
ABC124358
1​
4​
ABC124357
1​
5​
ABC124355
0​
6​
7​
Parts
8​
ABC123456
9​
ABC123457
10​
ABC123458
11​
ABC123459
12​
ABC123460

Note that the formula is array-entered.
 
Upvote 0
This could be faster or slower, dunno.

Code:
Function Transpositions(sInp As String) As String()
  Dim i As Long
  ReDim asout(1 To Len(sInp)) As String
  
  For i = 1 To Len(sInp) - 1
    asout(i) = sInp
    Mid(asout(i), i) = StrReverse(Mid(sInp, i, 2))
  Next i
  asout(i) = sInp
  
  Transpositions = asout
End Function
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,595
Members
449,089
Latest member
Motoracer88

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