Hello I have a column where there is data like this - (5-40-528) and would like to make the numbers in it 5-40-528 to appear in a different column
I don t want 3 separate columns just one. So that the number will be shown 5-30-071
[COLOR="Blue"]Function[/COLOR] Separate(Str [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]String[/COLOR]) [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]String[/COLOR]
[COLOR="Blue"]With[/COLOR] CreateObject("VBScript.RegExp")
.Pattern = "(\d+)-(\d+)-(\d+)"
Separate = .Execute(Str)(0)
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]With[/COLOR]
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Function[/COLOR]
Assuming the OP wants VB code, why not something a little simpler...May be this? UDF.
Code:[COLOR=blue]Function[/COLOR] Separate(Str [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR] [COLOR=blue]With[/COLOR] CreateObject("VBScript.RegExp") .Pattern = "(\d+)-(\d+)-(\d+)" Separate = .Execute(Str)(0) [COLOR=blue]End[/COLOR] [COLOR=blue]With[/COLOR] [COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
Function Separate(Str As String) As String
Separate = Mid(Str, 2, Len(Str) - 2)
End Function
[COLOR="Blue"]Function[/COLOR] Separate(Str [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]String[/COLOR]) [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]String[/COLOR]
Separate = Replace(Replace(Str, "(", ""), ")", "")
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Function[/COLOR]