Remove characters from string
Hi Ken,
i had put up this one before,
but didn't dare to post it.
Though perfection is not possible,
it might help you.
Sub Test()
Dim ba As Boolean ' "a" was found
Dim bp As Boolean ' "p" was found
Dim strC As String
Dim str1 As String
Dim str2 As String
Dim lngC As Long
str1 = "6:00am On Call"
For lngC = 1 To Len(str1)
strC = (Mid(str1, lngC, 1))
Select Case strC
Case "1" To "9": str2 = str2 & strC
Case "a"
If ba = False Then str2 = str2 & strC
ba = True
Case "p"
If bp = False Then str2 = str2 & strC
bp = True
End Select
Next
MsgBox str2
End Sub
G'day.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
|