• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Trim Function not working to remove leading space

Nitesh Khot

Member
Hi..
Attached file where string contains leading space but unable to remove using vba trim function.

How to remove leading space from string using VBA as trim function in vba working but not removing leading space.

Code:
For Each x In Selection
        x.Value = Application.WorksheetFunction.Trim(x.Value)
Next x
 

Attachments

  • Nikh.xlsx
    8.8 KB · Views: 4

Hi !

Either worksheet as VBA Trim functions work with true space (code #32) !
In your case, first character is char code #160 ! Bad copy from web ?
So just use Replace function to remove it or use Mid or Right functions …
 
Back
Top