Hi folks,
I have a simple UDF in Excel that is meant for extracting date from a given cell. The RegEx pattern works fine in online Regex101 tester but when used in Excel, I get "#Value " error. I have tried to figure it out, so far without any luck.
My date in Excel is put this way: Date: 02-DEC-15
Here is the function I am using:
Code:
Function getOrderDate(oDate As String)
Dim allDates As Object
Dim REDate As Object
Dim resultingDate
Set REDate = CreateObject("vbscript.regexp")
REDate.Pattern = "\d{2}\-\D{3}\-\d{2}" '"\d{2}\-\D{3}\-\d{2}"
REDate.Global = True
REDate.ignorecase = True
Set allDates = REDate.Execute(oDate)
If (allDates.Count <> 0) Then
resultingDate = allDates.Item(0).submatches.Item(0)
getOrderDate = resultingDate
End If
End Function
Your help would be much appreciated.