D
Diana
I am using this trimall macro for my data, the problem is
that it works fine for all the data except for cells that
have a value of 0032569. It is deleting the values 00
which is not good because if have several match formulas
in place. Is there any way to trimall and still keep the
00?
Sub TrimALL()
Application.ScreenUpdating = False
Cells.Select
'David McRitchie 2000-07-03 mod 2000-08-16 join.htm
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range
'Also Treat CHR 0160, as a space (CHR 032)
Selection.Replace What:=Chr(160), Replacement:=Chr(32),
_
LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:=False
'Trim in Excel removes extra internal spaces, VBA does
not
On Error Resume Next 'in case no text cells in
selection
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
cell.Value = Application.Trim(cell.Value)
Next cell
On Error GoTo 0
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
that it works fine for all the data except for cells that
have a value of 0032569. It is deleting the values 00
which is not good because if have several match formulas
in place. Is there any way to trimall and still keep the
00?
Sub TrimALL()
Application.ScreenUpdating = False
Cells.Select
'David McRitchie 2000-07-03 mod 2000-08-16 join.htm
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range
'Also Treat CHR 0160, as a space (CHR 032)
Selection.Replace What:=Chr(160), Replacement:=Chr(32),
_
LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:=False
'Trim in Excel removes extra internal spaces, VBA does
not
On Error Resume Next 'in case no text cells in
selection
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
cell.Value = Application.Trim(cell.Value)
Next cell
On Error GoTo 0
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub