hi Ron,
Can we do it reverse.pulling out only letters.
aa125df36 to aadf????
thank you
It's pretty simple. In the code I posted, you just need to change the "\D",
which selects all non-digits for removal, to a "\d" which selects all digits
for removal.
But for more flexibility, you could include the arguments for what to find, and
what to replace it with, in the function code.
For example, with this UDF:
=====================================
Option Explicit
Function ReSub(str As String, FindText As String, ReplaceWith As String)
Dim re As Object
Set re = CreateObject("VBScript.RegExp")
re.Global = True
re.Pattern = FindText
ReSub = re.Replace(str, ReplaceWith)
End Function
======================================
You could use this formula to replace all digits with a null string, resulting
in pulling out only letters:
=resub(A1,"\d","")
If you wanted to pull out only digits, then:
=resub(A1,"\D","")
If you wanted to replace the digits with a tilde, you could use:
=resub(A1,"\d","~")
If you wanted to replace all of the letters with the word Peyman, with leading
and ending spaces, then:
=resub(A6,"\D"," Peyman ")
And many other solutions
--ron