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:
ok - is it possible to check to character positions away? where the letters/numbers are transposed. Or would this too bring my computer to its knees? Really do appreciate your expertise!
 
Upvote 0

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.
Final suggestion.

Duplicate the list of part numbers. Sort the first list (col A) by part number. If some p/n look like numbers, ENSURE THEY ARE STORED AS STRINGS.

For the second list, use a UDF to sort the string, and sort that pair of columns (C:D) by the sort value.

Then,

A​
B​
C​
D​
1​
4716Match
2​
5107AnaMatch
3​
1234No Match
4​
p/n
p/n
sorted
5​
014001400014
6​
026014000014
7​
028505100015
8​
035102600026
9​
051060200026
10​
054736000036
11​
063270030037
12​
065367000067
13​
086320140124
14​
103920160126
15​
140040310134
16​
149203510135
17​
150431080138
18​
158210390139
19​
158431900139
20​
201439100139
21​
201615040145
22​
268041500145
23​
284084100148
24​
296191400149
25​
297571050157
26​
307651080158
27​
310891050159
28​
319068100168
29​
329561900169
30​
341997100179
31​
349243200234
32​
349806320236
33​
352783200238
34​
360093020239
35​
362145200245
36​
365250420245
37​
374054200245
38​
385028400248
39​
391062500256
40​
391802850258
41​
397450290259
42​
403126800268
43​
415092600269
44​
416879200279
45​
432037400347
46​
452006530356
47​
471657030357
48​
473638500358
49​
498353080358

In B1, =IF(VLOOKUP(A1, $A$5:$A$49, 1) = A1, "Match", IF(VLOOKUP(StrSort(A1), $D$5:$D$49, 1) = StrSort(A1), "AnaMatch", "No Match"))

In D5, =StrSort(C5)

Code:
Function StrSort(sInp As String, _
                 Optional bAsc As Boolean = True, _
                 Optional bCaseSens As Boolean = False) As String
  ' shg 2008, 2011
  ' UDF or VBA
  ' Insertion-sorts sInp

  Dim i             As Long
  Dim j             As Long
  Dim s             As String
  Dim iComp         As vbCompareMethod
  Dim iSign         As Long

  StrSort = sInp
  iComp = IIf(bCaseSens, vbBinaryCompare, vbTextCompare)
  iSign = IIf(bAsc, 1, -1)

  For i = 2 To Len(sInp)
    s = Mid$(StrSort, i, 1)

    For j = i - 1 To 1 Step -1
      If StrComp(Mid$(StrSort, j, 1), s, iComp) <> iSign Then Exit For
      Mid(StrSort, j + 1) = Mid$(StrSort, j, 1)
    Next j

    Mid(StrSort, j + 1) = s
  Next i
End Function
 
Upvote 0
If you put a workbook on box.net and post a link, I'll add the code.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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