I have trying to split numbers from letter a cell. The numbers can appear before or after the text, and sometimes the numbers can have two hypens (for SSN), two forward slashes (/) for dates, or a decimal point and/or dollar sign. if the numbers appear first, I need them to stay in the activecell and move the letters one cell to the right. If the letters appear first in the cell, I need the numbers move one cell to the right.
I have a script below that uses Regexp, the only problem is that is only works for the hypens and I need to add in the two backslashes, decimal point, and dollar sign. I tried a few variations but to no avail. Any ideas? Thanks..
Sub SplitTextNum()
Dim r As Range, rC As Range
Dim v As Variant
Set r = ActiveCell
With CreateObject("VBScript.RegExp")
.Pattern = "(\d+(\-\d+-\d+)?|\D+)"
.Global = True
For Each rC In r
v = Split(Mid(.Replace(rC.Value, "|$1"), 2), "|")
rC.Resize(, UBound(v) + 1).Value = v
Next rC
End With
End Sub
Bookmarks