Hello,
Im looking to use the VBA RTrim function to remove spaces from the end of the cell while preserving the spaces that exist inside the cell text. For example some cells look like this(_ as spaces) ABC__115____ I want to remove the spaces after the 5 but keep the spaces between c and 1.
I played with this code i found but it replaces all the values in my column d with the #value error. Can anyone help me?
Dim rng As Range
On Error Resume Next 'if entire column is blank, exit sub
Set rng = Intersect(Range("d1").EntireColumn, ActiveSheet.UsedRange)
rng.Value = Evaluate("IF(ROW(" & rng.Address & "),IF(" & rng.Address & _
"<>"""",rTRIM(" & rng.Address & "),""""))")
Im looking to use the VBA RTrim function to remove spaces from the end of the cell while preserving the spaces that exist inside the cell text. For example some cells look like this(_ as spaces) ABC__115____ I want to remove the spaces after the 5 but keep the spaces between c and 1.
I played with this code i found but it replaces all the values in my column d with the #value error. Can anyone help me?
Dim rng As Range
On Error Resume Next 'if entire column is blank, exit sub
Set rng = Intersect(Range("d1").EntireColumn, ActiveSheet.UsedRange)
rng.Value = Evaluate("IF(ROW(" & rng.Address & "),IF(" & rng.Address & _
"<>"""",rTRIM(" & rng.Address & "),""""))")