Hi,
Hoping for a helping hand please.
I have this bit of VBA that basically removes unwanted characters from a Text field:
The problem is, if the field is blank it shows as #error
Can you please advise how I can amend the code so that blank text fields stay blank and are not reported as #error?
Thanks for reading
Hoping for a helping hand please.
I have this bit of VBA that basically removes unwanted characters from a Text field:
Code:
Public Function StripOutVoidCharacters(varstring As String) As String
Dim varchar As String, i As Long, finalstring As String
For i = 1 To Len(varstring)
varchar = Mid(varstring, i, 1)
Select Case varchar
Case "'", "?", "/", "!", "%", "-", " ", ".", "+", "=", "\", "<", ">", ",", "!", "(", ")"
Case Else
finalstring = finalstring & varchar
End Select
Next i
StripOutVoidCharacters = finalstring
End Function
The problem is, if the field is blank it shows as #error
Can you please advise how I can amend the code so that blank text fields stay blank and are not reported as #error?
Thanks for reading