Results 1 to 10 of 15

Thread: Extracting Custom Pattern Consisting of Numbers & Text From Alphanumeric String

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    14
    Quote Originally Posted by larkspur View Post
    very interesting.... thanks snb, however I'd need your function to return the following formats:
    1. 3 letters LBC,ABC,FXI etc followed by 5 numerics, a back slash then 2 numerics e.g. 12540/01
    2. 2000 followed by 6 numerics
    3. 1800 followed by 6 numerics
    If you are interested in having the output as a comma delimited string within a single cell, like 'snb' assumed you wanted, as opposed to the multi-cell output of my original UDF, you could use the following UDF (note I used the same function name, so you would have to comment out or delete my previous UDF from your module before running this one)...
    Code:
    Function InvoiceNumbers(S As String) As String
      Dim X As Long, OutText As String
      For X = 1 To Len(S)
        If Mid(S, X, 11) Like "[A-Za-z][A-Za-z][A-Za-z]#####/##" Then
          OutText = OutText & ", " & Mid(S, X, 11)
        ElseIf Mid(S, X, 10) Like "2000######" Or Mid(S, X, 10) Like "1800######" Then
          OutText = OutText & ", " & Mid(S, X, 10)
        End If
      Next
      If Len(S) Then InvoiceNumbers = Mid(OutText, 3)
    End Function
    Note... unlike my previous UDF, this one can be placed anywhere (that is, it does not have to be placed next to the cell it is processing). Also, the calling formula would be the same....

    =InvoiceNumbers(A1)
    Last edited by Rick Rothstein; 05-22-2013 at 01:07 AM.

Similar Threads

  1. Extract Number From Alphanumeric Text
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 10
    Last Post: 09-11-2013, 10:14 PM
  2. Replies: 6
    Last Post: 06-01-2013, 03:24 PM
  3. Extracting Numeric Values From Alphanumeric Text
    By Safal Shrestha in forum Excel Help
    Replies: 3
    Last Post: 03-21-2013, 12:04 PM
  4. Find a text substring that matches a given "pattern"
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 2
    Last Post: 02-10-2013, 06:19 AM
  5. Extract numbers from alphanumeric values
    By tushar.tarafdar in forum Excel Help
    Replies: 3
    Last Post: 09-20-2012, 10:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •