Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
[email protected] BrianHolfield@hotmail.com is offline
external usenet poster
 
Posts: 3
Default Find&Replace character before end-of-cell mark

Find “AnytextA*” Replace “Anytext*”, where * represents the end-of-
cell marker. Parallel to replacing a character before ^p. Should be
dead simple, but apparently it aint. How to do it?
  #2   Report Post  
Posted to microsoft.public.word.tables
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Find&Replace character before end-of-cell mark

Unfortunately, MS has not (yet) provided any way to search for an
end-of-cell marker.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

wrote in message
...
Find “AnytextA*” Replace “Anytext*”, where * represents the end-of-
cell marker. Parallel to replacing a character before ^p. Should be
dead simple, but apparently it aint. How to do it?


  #3   Report Post  
Posted to microsoft.public.word.tables
[email protected] BrianHolfield@hotmail.com is offline
external usenet poster
 
Posts: 3
Default Find&Replace character before end-of-cell mark

On Sep 22, 10:31*am, "Suzanne S. Barnhill" wrote:
Unfortunately, MS has not (yet) provided any way to search for an
end-of-cell marker.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Yes, that much is clear. But isn’t there a programmatic approach? I
imagine saying: read the contents of a cell into variableX; right
truncate variableX by one character; paste variableX back into the
cell.
  #4   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Find&Replace character before end-of-cell mark

Use a macro containing the following code when the selection is in the table

Dim arng As Range
Dim i As Long, j As Long
With Selection.Tables(1)
For i = 1 To .Rows.Count
For j = 1 To .Columns.Count
Set arng = .Cell(i, j).Range
arng.End = arng.End - 1
If Right(arng.Words.Last, 1) = "A" Then
arng.Words.Last = Left(arng.Words.Last,
Len(arng.Words.Last) - 1)
End If
Next j
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

wrote in message
...
On Sep 22, 10:31 am, "Suzanne S. Barnhill" wrote:
Unfortunately, MS has not (yet) provided any way to search for an
end-of-cell marker.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Yes, that much is clear. But isn’t there a programmatic approach? I
imagine saying: read the contents of a cell into variableX; right
truncate variableX by one character; paste variableX back into the
cell.


  #5   Report Post  
Posted to microsoft.public.word.tables
[email protected] BrianHolfield@hotmail.com is offline
external usenet poster
 
Posts: 3
Default Find&Replace character before end-of-cell mark

On Sep 24, 1:32*am, "Doug Robbins - Word MVP"
wrote:
Use a macro containing the following code when the selection is in the table

Dim arng As Range
Dim i As Long, j As Long
With Selection.Tables(1)
* * For i = 1 To .Rows.Count
* * * * For j = 1 To .Columns.Count
* * * * * * Set arng = .Cell(i, j).Range
* * * * * * arng.End = arng.End - 1
* * * * * * If Right(arng.Words.Last, 1) = "A" Then
* * * * * * * * arng.Words.Last = Left(arng.Words.Last,
Len(arng.Words.Last) - 1)
* * * * * * End If
* * * * Next j
* * Next i
End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

wrote in message

...
On Sep 22, 10:31 am, "Suzanne S. Barnhill" wrote: Unfortunately, MS has not (yet) provided any way to search for an
end-of-cell marker.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA


Yes, that much is clear. But isn’t there a programmatic approach? I
imagine saying: read the contents of a cell into variableX; right
truncate variableX by one character; paste variableX back into the
cell.


Thanks, Doug. Works beautifully.


  #6   Report Post  
Posted to microsoft.public.word.tables
Shane Gidley Shane Gidley is offline
external usenet poster
 
Posts: 1
Default Almost there

This code looks great to remove every day characters, but the problem I have and that a lot of others on the web seem to have but cannot find answers to is how to remove a blank line at the end of the cell, or ^p. I tried replacing the "A" with "^p" of course, but it didn't work.
Any ideas for this?
  #7   Report Post  
Posted to microsoft.public.word.tables
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Almost there

Replace "A" with Chr(13) - no quotes

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Shane Gidley wrote:
This code looks great to remove every day characters, but the problem
I have and that a lot of others on the web seem to have but cannot
find answers to is how to remove a blank line at the end of the cell,
or ^p. I tried replacing the "A" with "^p" of course, but it didn't
work. Any ideas for this?



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and replace a character [email protected] Microsoft Word Help 1 September 27th 07 11:39 AM
Replace cannot find Paragraph Mark Dave C New Users 6 June 8th 07 05:53 AM
ü instead of a check mark when I try to copy it from Character Map Jim 90068 Microsoft Word Help 1 March 4th 07 11:25 PM
Find/Replace specific character michaelberrier Microsoft Word Help 3 January 24th 07 08:26 AM
Using find and replace with special character symbols wpfan Microsoft Word Help 1 October 4th 06 06:06 PM


All times are GMT +1. The time now is 08:55 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"