Here Is An Example Of The VBA Trim Function

The “Trim” function is useful in eliminating the blank spaces in a string
normally caused by some data entry error.

Why do you want to do this? Well because a sorting error can happen if you are trying to
sort ” Dan, “Fred”, and “Ann”. ” Dan” will show up on top before “Ann” because of that space.

I normally use the “Trim” function before the “Len” function (which checks the length of the string in VBA), otherwise I can get an incorrect string length.

In this example we’ll read the values of a column and we’ll clean up the string that
has some stray spaces.

Let me know if you have any questions, or click here for related posts

Free! Subscribe To Our YouTube Channel!

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather


Call Erik Now