Function CleanString(StrIn As String, Optional IsRemoveLineFeeds As Boolean = False) As String
' removes invisible characters, including carriage returns. By default, LINEFEEDS are NOT removed.
' to REMOVE LINEFEEDS, pass TRUE
' Does not remove special characters like symbols, international
' characters, etc. This function runs recursively, each call
' removing one embedded character
Dim iCh As Integer
Dim Ch As Integer 'a single character to be tested
CleanString = StrIn
For iCh = 1 To Len(StrIn)
Ch = Asc(Mid(StrIn, iCh, 1))
If Ch < 32 Then
' remove Ch 10 only if option is True
If (Ch <> 10) Or (Ch = 10 And IsRemoveLineFeeds) Then
'remove special character
CleanString = Left(StrIn, iCh - 1) & CleanString(Mid(StrIn, iCh + 1))
End If
Exit Function
End If
Next iCh
End Function