I\'m trying to delete the spaces that I have in each field of the column \"A\" this spaces are at the end of the string some of the string has 3 spaces others 4. When I run
In your specific case, the problem is that you're storing the replacement value in a string variable named result
, then doing nothing with it. If you want it to be in the Cell
, you have to add it back in there, such as:
Cells(I, "A").Value = result
Keep in mind, there is an Application.Trim
method that can actually save a bit of time over looping. Experiment with code such as:
Dim rng as Range
set rng = Range("A1:A10")
rng.Value = Application.Trim(rng)