Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Find & Replace part of cell contents

in Excel 2003 I've an input worksheet with text in some cells
some users formated their text using multiple spaces causing text length
problems

from another spreadsheet which is proofing the input I can locate the
problem cells

SrceFld ="D45"

Len(SrceBook.Sheets("InputSheet").Range(SrceFld).V alue)

I want to replace all cell contents occurances of " " with " " (double
space with single space)

I've tried
didn't change anything Replace
SrceBook.Sheets("InputSheet").Range(SrceFld).Value , " ", " ", 1, -1, 1

didn't change anything
SrceBook.Sheets("("InputSheet").Range(SrceFld).Rep lace What:=" ",
replacement:=" ", Lookat:=xlPart

Fails SrceBook.Sheets("Execute Dealer Plan").Range(SrceFld).Value.Replace
What:=" ", replacement:=" ", Lookat:=xlPart


--
Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Find & Replace part of cell contents

You can use the Trim function to replace leading, trailing, and
excessive spaces:
=Trim(A1)

Or
Range("A1")=WorksheetFunction.Trim(Range("A1"))

JASelep wrote:
in Excel 2003 I've an input worksheet with text in some cells
some users formated their text using multiple spaces causing text length
problems

from another spreadsheet which is proofing the input I can locate the
problem cells

SrceFld ="D45"

Len(SrceBook.Sheets("InputSheet").Range(SrceFld).V alue)

I want to replace all cell contents occurances of " " with " " (double
space with single space)

I've tried
didn't change anything Replace
SrceBook.Sheets("InputSheet").Range(SrceFld).Value , " ", " ", 1, -1, 1

didn't change anything
SrceBook.Sheets("("InputSheet").Range(SrceFld).Rep lace What:=" ",
replacement:=" ", Lookat:=xlPart

Fails SrceBook.Sheets("Execute Dealer Plan").Range(SrceFld).Value.Replace
What:=" ", replacement:=" ", Lookat:=xlPart


--
Jim


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Find & Replace part of cell contents

As I recall Trim only does leading and trailing spaces

users used spaces to essentially force wordwrap within the text window so I
have cell contents like...

"No National rally planned in our area like in 2006


Since the industry has taken a downturn, I
am expecting lower sales this year.


Perhaps production flexibility in the future with lower
cost alternate materials with compensate for projected rising costs in 2008."

--
Jim


"JW" wrote:

You can use the Trim function to replace leading, trailing, and
excessive spaces:
=Trim(A1)

Or
Range("A1")=WorksheetFunction.Trim(Range("A1"))

JASelep wrote:
in Excel 2003 I've an input worksheet with text in some cells
some users formated their text using multiple spaces causing text length
problems

from another spreadsheet which is proofing the input I can locate the
problem cells

SrceFld ="D45"

Len(SrceBook.Sheets("InputSheet").Range(SrceFld).V alue)

I want to replace all cell contents occurances of " " with " " (double
space with single space)

I've tried
didn't change anything Replace
SrceBook.Sheets("InputSheet").Range(SrceFld).Value , " ", " ", 1, -1, 1

didn't change anything
SrceBook.Sheets("("InputSheet").Range(SrceFld).Rep lace What:=" ",
replacement:=" ", Lookat:=xlPart

Fails SrceBook.Sheets("Execute Dealer Plan").Range(SrceFld).Value.Replace
What:=" ", replacement:=" ", Lookat:=xlPart


--
Jim



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find & Replace part of cell contents

VBA's Trim() only touches the leading and trailing spaces.

But JW used:
WorksheetFunction.Trim(Range("A1"))

And Excel's =trim() gets leading/trailing and duplicate embedded spaces.

JASelep wrote:

As I recall Trim only does leading and trailing spaces

users used spaces to essentially force wordwrap within the text window so I
have cell contents like...

"No National rally planned in our area like in 2006


Since the industry has taken a downturn, I
am expecting lower sales this year.


Perhaps production flexibility in the future with lower
cost alternate materials with compensate for projected rising costs in 2008."

--
Jim

"JW" wrote:

You can use the Trim function to replace leading, trailing, and
excessive spaces:
=Trim(A1)

Or
Range("A1")=WorksheetFunction.Trim(Range("A1"))

JASelep wrote:
in Excel 2003 I've an input worksheet with text in some cells
some users formated their text using multiple spaces causing text length
problems

from another spreadsheet which is proofing the input I can locate the
problem cells

SrceFld ="D45"

Len(SrceBook.Sheets("InputSheet").Range(SrceFld).V alue)

I want to replace all cell contents occurances of " " with " " (double
space with single space)

I've tried
didn't change anything Replace
SrceBook.Sheets("InputSheet").Range(SrceFld).Value , " ", " ", 1, -1, 1

didn't change anything
SrceBook.Sheets("("InputSheet").Range(SrceFld).Rep lace What:=" ",
replacement:=" ", Lookat:=xlPart

Fails SrceBook.Sheets("Execute Dealer Plan").Range(SrceFld).Value.Replace
What:=" ", replacement:=" ", Lookat:=xlPart


--
Jim




--

Dave Peterson
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
Find & Replace: find part cell, replace whole cell katy Excel Worksheet Functions 3 April 3rd 23 01:20 PM
Find & replace different years (part of the date)in a column krishna K Excel Worksheet Functions 1 May 31st 10 06:32 AM
find text in cell and replace it with part of the text in that ce. jules Excel Discussion (Misc queries) 3 May 3rd 07 10:18 AM
Find and replace part of a text string [email protected] Excel Discussion (Misc queries) 2 July 10th 06 10:34 PM
How do I find and replace part of a hyperlink that isn't visible? Dede Excel Discussion (Misc queries) 1 April 28th 05 12:15 AM


All times are GMT +1. The time now is 09:21 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"