I have a database in excel where in the row / column I have dates and words. Also, with dates before 1900. And, in some instances, only the year with 4 digits.
Example:
"A1" 20-07-1882 Daniel
or
"A2" 1882 João
I use, to separate the numbers of the words, this function:
Public Function SplitText(pWorkRng As Range, pIsNumber As Boolean) As String
Dim xLen As Long
Dim xStr As String
xLen = VBA.Len(pWorkRng.Value)
For i = 1 To xLen
xStr = VBA.Mid(pWorkRng.Value, i, 1)
If ((VBA.IsNumeric(xStr) And pIsNumber) Or (Not (VBA.IsNumeric(xStr)) And _
Not (pIsNumber))) Then
SplitText = SplitText + xStr
End If
Next
End Function
It works perfectly by using the "TRUE" parameter. However, in the case of the date in the short form, dd-mm-yyyy it removes the dash that separates the date ("-"), thus giving the result:
20071882
The idea here is that the trace is not removed at the time of separation.