Eliminate wild characters
Function WildStripper(stext) As String
Dim i As Long, j As Long
Dim ba1() As Byte, ba2() As Byte
Const cSTRIP As String = "~!@#$%^&*()"
ba1 = stext
ba2 = cSTRIP
For i = 0 To UBound(ba1) - 1 Step 2
For j = 0 To UBound(ba2)
If ba1(i) = ba2(j) Then
If ba1(i + 1) = ba2(j + 1) Then
ba1(i) = 32
ba1(i + 1) = 0
End If
End If
Next
Next
WildStripper = ba1
End Function
If you have many more characters to remove the above would probably be
faster adapted to use Select case.
This approach might not be suitable with 'wide' characters.
Regards,
Peter T
"MrRJ" wrote in message
...
Hi,
Is there a VBA code to eliminate wild characters ~!@#$%^&*() and replacing
them with a space?
I found this on this site and looks like it could work but need to
incoporate the wild characters and in a specific column.
Function RemAlpha(str As String) As String
With CreateObject("VbScript.RegExp")
.Global = True
.IgnoreCase = True
.Pattern = "[A-Z]"
RemAlpha = .Replace(str, vbNullString)
End With
End Function
I appreciate any help you can give.
|