You're welcome. Glad to help. Thanks for the feedback.
On Tue, 21 Aug 2007 11:32:00 -0700, peyman
wrote:
thank you so much.that's great!!!!!!!!!!
"Ron Rosenfeld" wrote:
On Tue, 21 Aug 2007 10:28:00 -0700, peyman
wrote:
hi,
how can I pull out numbers from a string?like:
aa012985 to 012985
12ab-059 to 12059
the letters or characters might be either at the first, middle or at the end
of a string.
thanx in advance.
You can use a UDF.
To enter the UDF, <alt-F11 opens the VB Editor.
Ensure your project is highlighted in the Project Explorer window, then
Insert/Module and paste the code below into the window that opens.
To use this UDF, enter =ExtrNums(cell_ref) into some cell.
===============================
Option Explicit
Function ExtrNums(str As String)
Dim re As Object
Set re = CreateObject("VBScript.RegExp")
re.Global = True
re.Pattern = "\D"
ExtrNums = re.Replace(str, "")
End Function
================================
--ron
--ron