Your posting raised made me realize my code needed to be modified. Why? I
didn't take into account that other characters may be colored with colors
other than white or the default (usually black)... my prior code makes every
character the default color (usually black). Here is modified code which
preserves the existing non-white character colors while deleting the white
characters...
Sub DeleteWhiteCharacters()
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim Chars As String
Dim Colors() As String
On Error GoTo Whoops
Application.ScreenUpdating = False
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = 1 To LastRow
Chars = .Cells(X, "A").Text
ReDim Colors(1 To Len(Chars))
For Z = 1 To Len(Chars)
If .Cells(X, "A").Characters(Z, 1).Font.ColorIndex = 2 Then
Mid(Chars, Z, 1) = Chr(1)
Colors(Z) = "XX"
Else
If .Cells(X, "A").Characters(Z, 1).Font.ColorIndex < 0 Then
Colors(Z) = "00"
Else
Colors(Z) = Format(.Cells(X, "A").Characters(Z,
1).Font.ColorIndex, "00")
End If
End If
Next
.Cells(X, "A").ClearContents
.Cells(X, "A").Value = Replace(Chars, Chr(1), "")
Colors =
Split(Application.WorksheetFunction.Trim(Replace(Join(Colors), "XX", "")))
For Z = 1 To UBound(Colors)
If Colors(Z - 1) <> "00" Then
.Cells(X, "A").Characters(Z, 1).Font.ColorIndex = CLng(Colors(Z -
1))
End If
Next
Next
End With
Whoops:
Application.ScreenUpdating = True
End Sub