PDA

View Full Version : [SOLVED] Extracting 8 digit PO from Field



jaydee
08-05-2019, 04:39 PM
Hi,

I am trying to exact an 8 digit PO number out of the description field. The issue is, the person was not consistent in the past, leading to them putting the PO number in the beginning, middle, and end. Is it somehow possible to exact this from the field?

I attached a sample, column B has what I was trying to get out of column A.

Thank you for your time and consideration.

Paul_Hossler
08-05-2019, 05:27 PM
Some of your data does not have 8 numbers in it



Option Explicit


Function PO(s As String) As String
Dim i As Long

PO = vbNullString

For i = 1 To Len(s) - 7
If Mid(s, i, 8) Like "########" Then
PO = Mid(s, i, 8)
Exit Function
End If
Next i
End Function

jaydee
08-07-2019, 02:28 PM
Thanks Paul!! worked awesome for our purposes!

We told the AP person that going forward to include it in the beginning so I could pull the number easier.

Have a great day and thank you for your help.