MISSING Alphanumeric Sequence

mkemp

New Member
Joined
Oct 16, 2018
Messages
3
Greets,
I am trying to determine the easiest way to find a missing alphanumeric, alpha, or numeric sequence in a excel. I believe the functionality is already there in excel just not sure how to do it or where to start. Any help would be appreciated.

Use Case: I am trying to find all the missing alphanumeric or alpha sequence in a column. The constant is that the sequence is always alpha leading A-Z and is 3 characters in length. The sequence is always A-Z or 0-9.

Example data:

AA1
AE0
AE1
AE2
AE3
AE4
AE5
AE6
AE7
AE8
AE9
AMS
AO0
AO2
AO3
AO4
AO5
AO6
AO7
AO9

Function would return something like this below.

AAA
AAB
AAC
AAD
AAE
AAF etc ....


AA0
AA2
AA3
AA4
AA5
AA6
AA7
AA8
AA9
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I'm not sure what a complete sequence would look like.

I would create a function that takes a string as its argument and returns the next string in your sequence.

Then use that UDF to determine if each cell was the NextInLine of the previous cell.
 
Upvote 0
[Table="width:, class:grid"][tr][td="bgcolor:#C0C0C0"][/td][td="bgcolor:#C0C0C0"]
A​
[/td][td="bgcolor:#C0C0C0"]
B​
[/td][/tr][tr][td="bgcolor:#C0C0C0"]
1​
[/td][td]AA1[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
2​
[/td][td]AE0[/td][td="bgcolor:#CCFFCC"]AA2,AA3,AA4,AA5,AA6,AA7,AA8,AA9,AAA,AAB,AAC,AAD,AAE,AAF,AAG,AAH,AAI,AAJ,AAK,AAL,AAM,AAN,AAO,AAP,AAQ,AAR,AAS,AAT,AAU,AAV,AAW,AAX,AAY,AAZ,AB0,AB1,AB2,AB3,AB4,AB5,AB6,AB7,AB8,AB9,ABA,ABB,ABC,ABD,ABE,ABF,ABG,ABH,ABI,ABJ,ABK,ABL,ABM,ABN,ABO,ABP,ABQ,ABR,ABS,ABT,ABU,ABV,ABW,ABX,ABY,ABZ,AC0,AC1,AC2,AC3,AC4,AC5,AC6,AC7,AC8,AC9,ACA,ACB,ACC,ACD,ACE,ACF,ACG,ACH,ACI,ACJ,ACK,ACL,ACM,ACN,ACO,ACP,ACQ,ACR,ACS,ACT,ACU,ACV,ACW,ACX,ACY,ACZ,AD0,AD1,AD2,AD3,AD4,AD5,AD6,AD7,AD8,AD9,ADA,ADB,ADC,ADD,ADE,ADF,ADG,ADH,ADI,ADJ,ADK,ADL,ADM,ADN,ADO,ADP,ADQ,ADR,ADS,ADT,ADU,ADV,ADW,ADX,ADY,ADZ[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
3​
[/td][td]AE1[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
4​
[/td][td]AE2[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
5​
[/td][td]AE3[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
6​
[/td][td]AE4[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
7​
[/td][td]AE5[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
8​
[/td][td]AE6[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
9​
[/td][td]AE7[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
10​
[/td][td]AE8[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
11​
[/td][td]AE9[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
12​
[/td][td]AMS[/td][td="bgcolor:#CCFFCC"]AEA,AEB,AEC,AED,AEE,AEF,AEG,AEH,AEI,AEJ,AEK,AEL,AEM,AEN,AEO,AEP,AEQ,AER,AES,AET,AEU,AEV,AEW,AEX,AEY,AEZ,AF0,AF1,AF2,AF3,AF4,AF5,AF6,AF7,AF8,AF9,AFA,AFB,AFC,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,AMA,AMB,AMC,AMD,AME,AMF,AMG,AMH,AMI,AMJ,AMK,AML,AMM,AMN,AMO,AMP,AMQ,AMR[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
13​
[/td][td]AO0[/td][td="bgcolor:#CCFFCC"]AMT,AMU,AMV,AMW,AMX,AMY,AMZ,AN0,AN1,AN2,AN3,AN4,AN5,AN6,AN7,AN8,AN9,ANA,ANB,ANC,AND,ANE,ANF,ANG,ANH,ANI,ANJ,ANK,ANL,ANM,ANN,ANO,ANP,ANQ,ANR,ANS,ANT,ANU,ANV,ANW,ANX,ANY,ANZ[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
14​
[/td][td]AO2[/td][td="bgcolor:#CCFFCC"]AO1[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
15​
[/td][td]AO3[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
16​
[/td][td]AO4[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
17​
[/td][td]AO5[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
18​
[/td][td]AO6[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
19​
[/td][td]AO7[/td][td="bgcolor:#CCFFCC"][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
20​
[/td][td]AO9[/td][td="bgcolor:#CCFFCC"]AO8[/td][/tr]
[/table]


In A2 and copied down,

=WhatsMissing(A1, A2, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")

Code:
Function DecToBij(iNum As Long, sSym As String) As String
  ' shg 2014
  ' VBA or UDF

  ' Base sSym
  '   1  "1" (Tally)
  '   2  "12"
  '  10  "123456789A"
  '  26  "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (Excel)

  ' Returns the bijective numeral for iNum using the digits in sSym

  ' https://en.wikipedia.org/wiki/Bijective_numeration
  ' https://en.wikipedia.org/wiki/Shortlex_order

  If iNum > 0 Then DecToBij = DecToBij((iNum - 1) \ Len(sSym), sSym) & _
     Mid(sSym, ((iNum - 1) Mod Len(sSym)) + 1, 1)
End Function

Function BijToDec(sBij As String, sSym As String) As Long
  ' shg 2014
  ' VBA or UDF
  ' Returns the decimal value for the bijective numeral in sBij

  ' https://en.wikipedia.org/wiki/Bijective_numeration
  ' https://en.wikipedia.org/wiki/Shortlex_order

  If Len(sBij) Then BijToDec = InStr(sSym, Right(sBij, 1)) _
     + Len(sSym) * BijToDec(Left(sBij, Len(sBij) - 1), sSym)
End Function

Function WhatsMissing(s1 As String, s2 As String, sSym As String) As String
  Dim i             As Long
  Dim i1            As Long
  Dim i2            As Long
  Dim asOut()       As String

  i1 = BijToDec(s1, sSym)
  i2 = BijToDec(s2, sSym)

  If i2 > i1 + 1 Then
    ReDim asOut(i1 + 1 To i2 - 1)
    For i = i1 + 1 To i2 - 1
      asOut(i) = DecToBij(i, sSym)
    Next i
  WhatsMissing = Join(asOut, ",")
  End If
End Function
 
Upvote 0
I was able to create the UDF with the code you provided. I am still unable to get the results like you have here.



[TABLE="class: grid"]
<tbody>[TR]
[TD="bgcolor: #C0C0C0"][/TD]
[TD="bgcolor: #C0C0C0"]
A​
[/TD]
[TD="bgcolor: #C0C0C0"]
B​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #C0C0C0"]
1​
[/TD]
[TD]AA1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #C0C0C0"]
2​
[/TD]
[TD]AE0[/TD]
[TD="bgcolor: #CCFFCC"]AA2,AA3,AA4,AA5,AA6,AA7,AA8,AA9,AAA,AAB,AAC,AAD,AAE,AAF,AAG,AAH,AAI,AAJ,AAK,AAL,AAM,AAN,AAO,AAP,AAQ,AAR,AAS,AAT,AAU,AAV,AAW,AAX,AAY,AAZ,AB0,AB1,AB2,AB3,AB4,AB5,AB6,AB7,AB8,AB9,ABA,ABB,ABC,ABD,ABE,ABF,ABG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
19​
[/TD]
[TD]AO7[/TD]
[TD="bgcolor: #CCFFCC"][/TD]
[/TR]
[TR]
[TD="bgcolor: #C0C0C0"]
20​
[/TD]
[TD]AO9[/TD]
[TD="bgcolor: #CCFFCC"]AO8[/TD]
[/TR]
</tbody>[/TABLE]


In A2 and copied down,

=WhatsMissing(A1, A2, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")

Code:
Function DecToBij(iNum As Long, sSym As String) As String
  ' shg 2014
  ' VBA or UDF

  ' Base sSym
  '   1  "1" (Tally)
  '   2  "12"
  '  10  "123456789A"
  '  26  "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (Excel)

  ' Returns the bijective numeral for iNum using the digits in sSym

  ' https://en.wikipedia.org/wiki/Bijective_numeration
  ' https://en.wikipedia.org/wiki/Shortlex_order

  If iNum > 0 Then DecToBij = DecToBij((iNum - 1) \ Len(sSym), sSym) & _
     Mid(sSym, ((iNum - 1) Mod Len(sSym)) + 1, 1)
End Function

Function BijToDec(sBij As String, sSym As String) As Long
  ' shg 2014
  ' VBA or UDF
  ' Returns the decimal value for the bijective numeral in sBij

  ' https://en.wikipedia.org/wiki/Bijective_numeration
  ' https://en.wikipedia.org/wiki/Shortlex_order

  If Len(sBij) Then BijToDec = InStr(sSym, Right(sBij, 1)) _
     + Len(sSym) * BijToDec(Left(sBij, Len(sBij) - 1), sSym)
End Function

Function WhatsMissing(s1 As String, s2 As String, sSym As String) As String
  Dim i             As Long
  Dim i1            As Long
  Dim i2            As Long
  Dim asOut()       As String

  i1 = BijToDec(s1, sSym)
  i2 = BijToDec(s2, sSym)

  If i2 > i1 + 1 Then
    ReDim asOut(i1 + 1 To i2 - 1)
    For i = i1 + 1 To i2 - 1
      asOut(i) = DecToBij(i, sSym)
    Next i
  WhatsMissing = Join(asOut, ",")
  End If
End Function
 
Upvote 0
There's nothing for you to create; all the code is posted.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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