Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How can I remove all spaces following the last character in a cell

How can I remove all spaces following the last character in a cell?  In other words...

"# 264,265 BTMPI, # 266  CLINK                  53 after            "

would end up like...

"# 264,265 BTMPI, # 266  CLINK                  53 after"

(without the quote marks)

--Steve
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

=TRIM(your cell address)
=IF(LEN(TRIM(A1)),REPLACE(LEFT(A1,LOOKUP(2^15,FIND(RIGHT(TRIM(A1)),A1,ROW(INDIRECT("1:"&LEN(A1)))))),1,FIND(LEFT(TRIM(A1)),A1)-1,""),"")

Courtesy barryhoudini
Avatar of SteveL13

ASKER

=TRIM(your cell address)   didn't do anything.  I copied the formula into the space at the top of the spreadsheet as =TRIM(C2) which is the real field I want trimmed and nothing happened other than =TRIM(C2) appeared in cell D2 ???????????


The same thing happens with...   =IF(LEN(TRIM(A1)),REPLACE(LEFT(A1,LOOKUP(2^15,FIND(RIGHT(TRIM(A1)),A1,ROW(INDIRECT("1:"&LEN(A1)))))),1,FIND(LEFT(TRIM(A1)),A1)-1,""),"")

The formula just appears in D2.

I'm sure I'm doing something wrong.
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial