What's happened to TRIM?

G

Guest

Being a VBA coder, rather than a spreadsheet designer, I don't play with the worksheet functions too often, and thus was somewhat surprised to discover that MS has 'updated' the TRIM function. Apparently it now removes not only the spaces at the start and end of a string, but it also replaces multiple instances of spaces within the text. This has just added a substantial amount of effort to my current task, as I now have to write a replacement function that behaves the way TRIM used to do. It wouldn't be so bad if MS had decided to include LTRIM/RTRIM. Does anyone know why they decided to do this, has it been 'fixed' in Excel 2003?
 
C

Chip Pearson

As far as I can tell, the TRIM worksheet function and the Trim
VBA function work the same in Excel 2003 as they did in earlier
versions. What difference have you found?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



<aHappyMicrosoftUser>; ")" <[email protected]>
wrote in message
Being a VBA coder, rather than a spreadsheet designer, I don't
play with the worksheet functions too often, and thus was
somewhat surprised to discover that MS has 'updated' the TRIM
function. Apparently it now removes not only the spaces at the
start and end of a string, but it also replaces multiple
instances of spaces within the text. This has just added a
substantial amount of effort to my current task, as I now have to
write a replacement function that behaves the way TRIM used to
do. It wouldn't be so bad if MS had decided to include
LTRIM/RTRIM. Does anyone know why they decided to do this, has
it been 'fixed' in Excel 2003?
 
G

Guest

It used to just strip leading and trailing spaces only, not compact multiple spaces in the body of the text down to one, eg " a b " would become "a b" rather than "a b" as it does now.


----- Chip Pearson wrote: ----

As far as I can tell, the TRIM worksheet function and the Tri
VBA function work the same in Excel 2003 as they did in earlie
versions. What difference have you found


--
Cordially
Chip Pearso
Microsoft MVP - Exce
Pearson Software Consulting, LL
www.cpearson.co
 
K

Ken Wright

2000/02/03 all work the same. Leading / Trailing / Multiple spaces are removed.
There was no change in 2003 that I can see, and I can't replicate the behaviour
you refer to in any other version using the standard worksheet function TRIM().

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :)
----------------------------------------------------------------------------



It used to just strip leading and trailing spaces only, not compact multiple
spaces in the body of the text down to one, eg " a b " would become "a
b" rather than "a b" as it does now.
 
C

Chip Pearson

The worksheet function TRIM has, at least since 97, removed
internal spaces. The VBA function Trim does not. There are no
changes in Excel 2003.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


<aHappyMicrosoftUser>; ")" <[email protected]>
wrote in message
It used to just strip leading and trailing spaces only, not
compact multiple spaces in the body of the text down to one, eg "
a b " would become "a b" rather than "a b" as it does
now.
 
R

Ron Rosenfeld

Being a VBA coder, rather than a spreadsheet designer, I don't play with the worksheet functions too often, and thus was somewhat surprised to discover that MS has 'updated' the TRIM function. Apparently it now removes not only the spaces at the start and end of a string, but it also replaces multiple instances of spaces within the text. This has just added a substantial amount of effort to my current task, as I now have to write a replacement function that behaves the way TRIM used to do. It wouldn't be so bad if MS had decided to include LTRIM/RTRIM. Does anyone know why they decided to do this, has it been 'fixed' in Excel 2003?


Why not just use the VBA function TRIM? That would seem to work the way you
require and it should be trivial to write a UDF to use it.

I don't think the worksheet function TRIM has changed. I think it has always
been different from the VBA function, at least for a number of years.


--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top