Evaluate function using Trim not working

  • Hi,

    I'm trying to use the following code to remove any leading or trailing spaces from values
    in column "C" of my worksheet:

    With Range(Cells(3, "C"), Cells(Rows.Count, "C").End(xlUp)         .Value = Evaluate(Trim(" & .Address & "))    End With

    Starting with initial values in column "C" of: J9768A, JC028A#A1X, JC085A, etc.,
    after running the above mentioned code, I get "#VALUE!" in all of the cells in column "C".
    Additionally, I tried to substitute ".Value" for ".Address" but get the same result.
    Any ideas why I'm getting the "#VALUE!" result?

    Thank You for any help provided.

  • Re: Evaluate function using Trim not working


    Dim Rng As Range
    Set Rng = Range(Range("C1"), Range("C" & Rows.Count).End(xlUp))
    Rng.Value = Evaluate("if(row(), trim(" & Rng.Address & "))")

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!