Thursday, November 21, 2013

What if excel can't remove trailing space using TRIM function


Today i wondered when excel clean and trim function could not do what it supposed to. Reason was content was copied from net and have trailing spaces. These trailing spaces are due to &nbsp which is hidden.

so I used below function within excel to get the removed trailing spaces
=TRIM(SUBSTITUTE(B1,CHAR(160),CHAR(32)))

First substitute  ASCII character for &nbsp i.e. 160 with the ASCII code for normal space i.e. 32
and in last TRIM will do it's job.

No comments:

Post a Comment