Skip to content

Instantly share code, notes, and snippets.

@ezhov-da
Created March 12, 2023 14:05
Show Gist options
  • Save ezhov-da/725f0e5651c9a7d07ac489027776724c to your computer and use it in GitHub Desktop.
Save ezhov-da/725f0e5651c9a7d07ac489027776724c to your computer and use it in GitHub Desktop.
Function EXTRACT_CODE(cell)
Dim result As String
Dim allMatches As Object
Dim RE As Object
Set RE = CreateObject("vbscript.regexp")
RE.Pattern = "[0-9]{6}"
RE.Global = True
RE.IgnoreCase = True
Set allMatches = RE.Execute(cell)
If allMatches.Count <> 0 Then
result = allMatches.Item(0).value
End If
EXTRACT_CODE = result
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment