Re: Extract letters and numbers from string
- From: Gary''s Student <GarysStudent@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 29 Feb 2008 09:48:02 -0800
A great tip ! Thank you very much for taking the time to share.
--
Gary''s Student - gsnu200771
"Rick Rothstein (MVP - VB)" wrote:
In this statement of yours.....
If sChar Like "[0-9]" Or sChar Like "[a-z]" Or sChar Like "[A-Z]" Then
the Like pattern tests can all be included into a single pattern test...
If sChar Like "[0-9a-zA-Z]" Then
Rick
"Gary''s Student" <GarysStudent@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BDCD8F73-9BCE-4F95-9F06-AF7C3338F32A@xxxxxxxxxxxxxxxx
Here is one way. Try this UDF:
Public Function AlphaNumerals(rng As Range) As String
'
' gsnuxx
'
Dim sStr As String, i As Long, sStr1 As String
Dim sChar As String
sStr = rng.Value
For i = 1 To Len(sStr)
sChar = Mid(sStr, i, 1)
If sChar Like "[0-9]" Or sChar Like "[a-z]" Or sChar Like "[A-Z]" Then
sStr1 = sStr1 & sChar
End If
Next
AlphaNumerals = sStr1
End Function
--
Gary''s Student - gsnu2007d
"ward376" wrote:
What's the best way to extract alpha and numeric characters from a
string?
I'm pulling the sender and subject info from Lotus Notes emails and
prefixing them to attachments' file names stripped from those emails,
so I have to lose the other characters in the extracted strings to fit
file-naming rules. I started to replace them, but Excel doesn't seem
to find some of the special characters - and there are so many it
seems it would be easier to identify alpha/numeric than illegal
characters.
Thanks!
Cliff Edwards
- Follow-Ups:
- Re: Extract letters and numbers from string
- From: Rick Rothstein \(MVP - VB\)
- Re: Extract letters and numbers from string
- References:
- Extract letters and numbers from string
- From: ward376
- Re: Extract letters and numbers from string
- From: Rick Rothstein \(MVP - VB\)
- Extract letters and numbers from string
- Prev by Date: VBA to reference one cell in a range of one or more cells
- Next by Date: Re: Distribute Addin
- Previous by thread: Re: Extract letters and numbers from string
- Next by thread: Re: Extract letters and numbers from string
- Index(es):
Relevant Pages
|