#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 29
Default trailing spaces

Hi,
Found these formulas on the web
=LEFT(A803,MATCH(2,1/(MID(A803,ROW(INDEX($1:$65536,1,1):INDEX($1:$65536 ,LEN(A803),1)),1)<" "))) (an array) deletes trailing spaces

=REPLACE(A804,1,FIND(LEFT(TRIM(A804),1),A804)-1,"")
deletes beginning spaces

Is it possible to combine these into one formula to remove both beginning and
trailing spaces? I can't use trim because it will also remove duplicate
inbeded
spaces.

thanks,

peter


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default trailing spaces

Take advantage of the fact that in VBA TRIM dows not touch internal spaces at
all. Use this tiny UDF:

Function NotSoTrim(r As Range) As String
NotSoTrim = Trim(r.Value)
End Function
--
Gary''s Student - gsnu200750


"peter" wrote:

Hi,
Found these formulas on the web
=LEFT(A803,MATCH(2,1/(MID(A803,ROW(INDEX($1:$65536,1,1):INDEX($1:$65536 ,LEN(A803),1)),1)<" "))) (an array) deletes trailing spaces

=REPLACE(A804,1,FIND(LEFT(TRIM(A804),1),A804)-1,"")
deletes beginning spaces

Is it possible to combine these into one formula to remove both beginning and
trailing spaces? I can't use trim because it will also remove duplicate
inbeded
spaces.

thanks,

peter


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default trailing spaces

If you can't use the macro that Gary's Student suggested, then consider this
formula which will trim only the outside spaces...

=LEFT(SUBSTITUTE(MID(A1,FIND(LEFT(TRIM(A1),1),A1), 1000),RIGHT(TRIM(A1)),RIGHT(TRIM(A1))&"|",LEN(A1)-LEN(SUBSTITUTE(A1,RIGHT(TRIM(A1)),""))),FIND("|",S UBSTITUTE(MID(A1,FIND(LEFT(TRIM(A1),1),A1),1000),R IGHT(TRIM(A1)),RIGHT(TRIM(A1))&"|",LEN(A1)-LEN(SUBSTITUTE(A1,RIGHT(TRIM(A1)),""))))-1)

Rick


"peter" wrote in message
...
Hi,
Found these formulas on the web
=LEFT(A803,MATCH(2,1/(MID(A803,ROW(INDEX($1:$65536,1,1):INDEX($1:$65536 ,LEN(A803),1)),1)<"
"))) (an array) deletes trailing spaces

=REPLACE(A804,1,FIND(LEFT(TRIM(A804),1),A804)-1,"")
deletes beginning spaces

Is it possible to combine these into one formula to remove both beginning
and
trailing spaces? I can't use trim because it will also remove duplicate
inbeded
spaces.

thanks,

peter



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 29
Default trailing spaces

Thank you both very much.

peter


"Rick Rothstein (MVP - VB)" wrote:

If you can't use the macro that Gary's Student suggested, then consider this
formula which will trim only the outside spaces...

=LEFT(SUBSTITUTE(MID(A1,FIND(LEFT(TRIM(A1),1),A1), 1000),RIGHT(TRIM(A1)),RIGHT(TRIM(A1))&"|",LEN(A1)-LEN(SUBSTITUTE(A1,RIGHT(TRIM(A1)),""))),FIND("|",S UBSTITUTE(MID(A1,FIND(LEFT(TRIM(A1),1),A1),1000),R IGHT(TRIM(A1)),RIGHT(TRIM(A1))&"|",LEN(A1)-LEN(SUBSTITUTE(A1,RIGHT(TRIM(A1)),""))))-1)

Rick


"peter" wrote in message
...
Hi,
Found these formulas on the web
=LEFT(A803,MATCH(2,1/(MID(A803,ROW(INDEX($1:$65536,1,1):INDEX($1:$65536 ,LEN(A803),1)),1)<"
"))) (an array) deletes trailing spaces

=REPLACE(A804,1,FIND(LEFT(TRIM(A804),1),A804)-1,"")
deletes beginning spaces

Is it possible to combine these into one formula to remove both beginning
and
trailing spaces? I can't use trim because it will also remove duplicate
inbeded
spaces.

thanks,

peter




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing leading/trailing spaces Chuda Excel Discussion (Misc queries) 2 September 12th 06 04:20 PM
REMOVING TRAILING SPACES Tris Excel Discussion (Misc queries) 5 August 29th 06 03:36 PM
remove trailing spaces les8 Excel Discussion (Misc queries) 4 January 20th 06 03:55 PM
Trailing spaces in Pivot tables Fred Excel Worksheet Functions 1 May 6th 05 01:59 PM
Removing trailing spaces from cells ? Don Guillett Excel Worksheet Functions 0 April 10th 05 03:32 PM


All times are GMT +1. The time now is 07:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"