Extract text from alphanumeric strings. Formula, udf or code.

This is a discussion on Extract text from alphanumeric strings. Formula, udf or code. within the Excel Questions forums, part of the Question Forums category; hi,
I have many registers with alphanumeric strings.
I want to extract only the text from these cells.
I have:
...

Re: Extract text from alphanumeric strings. Formula, udf or code.

Hi jesma12,

Though it would be advisable to have started a new thread with a link back to this one, see how this goes:

Code:

Function AlphaExtract(txt As String, Optional varDefaultVal As Variant) As String
'Use in a cell like any Excel function, i.e. _
=AlphaExtract(A4,"cups")
'will extract the text from A4 or return 'cups' _
(though this can be text or a value) if there's no text in A4.
With CreateObject("VBScript.RegExp")
.Pattern = ("\d+")
.Global = True
AlphaExtract = .Replace(txt, "")
End With
If AlphaExtract = "" Then AlphaExtract = varDefaultVal
End Function