I found this snippet on the web to trim the leading and trailing spaces:
However, stepping through it I found it not to work. I think this is because the characters are not standard spaces. (What exactly they are, I don't know).
The good news is, there is always two of these characters on the right side of the value that needs to be trimmed. Unfortunately, I am unfamiliar with VBA. How would I trim the last two characters from MyCell?
In c++ parlance:
MyCell = MyCell.substr(MyCell.begin(),MyCell.end()-2);
Thank you.
Code:
Sub TrimRText()
' This module will trim extra spaces from RIGHT SIDE.
Dim MyCell As Range
On Error Resume Next
Selection.Cells.SpecialCells(xlCellTypeConstants, 23).Select
For Each MyCell In Selection.Cells
MyCell.Value = Application.Trim(MyCell.Value)
Next
On Error GoTo 0
End Sub
However, stepping through it I found it not to work. I think this is because the characters are not standard spaces. (What exactly they are, I don't know).
The good news is, there is always two of these characters on the right side of the value that needs to be trimmed. Unfortunately, I am unfamiliar with VBA. How would I trim the last two characters from MyCell?
In c++ parlance:
MyCell = MyCell.substr(MyCell.begin(),MyCell.end()-2);
Thank you.