I've used How to remove all non alphanumeric characters from a string except period and space in excel? but keep getting
Object required
You can see around the text where I have tried various Err or If statements but these have sadly not fixed it.
Sub CleanAll()
Set wb = Workbooks("test.xlsm")
Dim rng As Range
' Dim i As Integer
' i = 1
For Each rng In wb.Sheets("Portal_Aligned").Range("A1:AX9999").Cells 'adjust sheetname and range accordingly
rng.Value = CleanCode(rng.Value) & ""
' i = i + 1
Next
End Sub
Function CleanCode(strSource As String) As String
'On Error GoTo Err1
'http://www.asciitable.com/
Dim i As Integer
Dim strResult As String
' If strSource <> "" Then
For i = 1 To Len(strSource)
Select Case Asc(Mid(strSource, i, 1))
Case 32 To 33, 35 To 131, 133 To 135, 145 To 146, 150 To 152, 155, 162 To 166, 183, 188 To 190, 247
strResult = strResult & Mid(strSource, i, 1)
End Select
Next
'AlphaNumericOnly = strResult
'rng.Value = AlphaNumericOnly(rng.Value)
' End If
Err1:
End Function