(Q) How do I extract only characters from a string which has both numeric and
alphanumeric characters?
(A) Use the following function. Note that the If loop can be modified to extract either
both Lower and Upper case character or either Lower or Upper case characters.
Function fExtractStr(ByVal strInString As String) As String
Dim lngLen As Long, strOut As String
Dim i As Long, strTmp As String
lngLen = Len(strInString)
strOut = ""
For i = 1 To lngLen
strTmp = Left$(strInString, 1)
strInString = right$(strInString, lngLen - i)
If (Asc(strTmp) >= 65 And Asc(strTmp) <= 90) Or _
(Asc(strTmp) >= 97 And Asc(strTmp) <= 122) Then
strOut = strOut & strTmp
End If
Next i
fExtractStr = strOut
End Function
|