View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
George Kibuuka George Kibuuka is offline
external usenet poster
 
Posts: 1
Default Macro for deleting non-printable characters from EXCEL

I Have written the function below to remove some non printable characters
from my WORKBOOK.
However when I run the code it delete all entries from my worksheets.

Sub Clean()
Dim j As Integer
Dim vAddText

Application.DisplayAlerts = False
Application.StatusBar = "Starting cleaning of workbook " &
Application.ActiveWorkbook.FullName
On Error GoTo 0
vAddText = Array(Chr(129), Chr(141), Chr(143), Chr(144), Chr(157))
For J = 1 To 31
If J < 10 Then Cells.Replace What:=Chr(J), Replacement:="",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next
For J = 0 To UBound(vAddText)
Cells.Replace What:=vAddText(J), Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next
Application.StatusBar = "Ending cleaning of workbook " &
Application.ActiveWorkbook.FullName
Application.DisplayAlerts = True
End Sub

--
George, Southampton, UK