I have a column of cells that have a bunch of text in them. in that text there are serial numbers I would like to extract. A cell could have multiple different serial numbers that need to be extracted. For example a cell could have: "Exchange + PS43138 Exchange + PS43178" I'm interested in trying to get both the serial numbers out PS43138 and PS43178. the serial numbers differ slightly, but they all have a 5 digit string of numbers. I tried to create a UDF but can'f figure out how to get all serial numbers out, I can only get the first one. This is the UDF I got from the looking through the forum.
Any help would be much appreciated.
Thanks,
Code:
Function FiveDigitNo(s As String) As StringWith CreateObject("VBScript.RegExp")
.Pattern = "(?:^|\D)(\d{5})(?!\d)"
If .Test(s) Then FiveDigitNo = .Execute(s)(0).SubMatches(0)
End With
End Function
Any help would be much appreciated.
Thanks,