can you upload example, would be easier to view
--
Message posted from http://www.ExcelForum.com
You can search for the space at the end of the word, and replace to that
point:
=REPLACE(I2,SEARCH(E2,I2),
SEARCH(" ",I2,SEARCH(E2,I2))-SEARCH(E2,I2),".....")
> I have the following function which replaces a word in a sentence with
> "....."
[quoted text clipped - 8 lines]
> Any ideas how I could capture any remaining letters at the end of the
> word and get the result "I ..... at home"?

Signature
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html
Runt - 14 Apr 2004 09:52 GMT
The solution you gave...
> =REPLACE(I2,SEARCH(E2,I2),
> SEARCH(" ",I2,SEARCH(E2,I2))-SEARCH(E2,I2),"....."
...is excellent except that it doesn't replace the word if it is at
the end of the sentence because of the lack of a space or the
existance of a full-stop (a.k.a period).
Is there any way around this?
Thanks,
Chris
> You can search for the space at the end of the word, and replace to that
> point:
[quoted text clipped - 14 lines]
> > Any ideas how I could capture any remaining letters at the end of the
> > word and get the result "I ..... at home"?
Runt - 14 Apr 2004 10:25 GMT
I seem to have solve the end-of-sentence problem by substituting the
punctuation for spaces as follows:
=REPLACE(I2,SEARCH(E2,I2), SEARCH(" ",SUBSTITUTE(SUBSTITUTE(I2,".","
"),"?"," "),SEARCH(E2,I2))-SEARCH(E2,I2),".....")
But, I've stumbled across a complication which has stretched my tiny
brain to its limit.
If the text in cell (E2) has a space in it, such as "TRYING TO" and I
want to remove it from the sentence "I am TRYING TO remove this.",
then I am getting
"I ..... TO remove this." instead of
"I ..... remove this." which is what I want.
Any ideas?
Cheers,
Chris
> You can search for the space at the end of the word, and replace to that
> point:
[quoted text clipped - 14 lines]
> > Any ideas how I could capture any remaining letters at the end of the
> > word and get the result "I ..... at home"?