Find & Replace Question (To end of Line)

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have some documents that start a line of text with a
common message and then finish with a unique set of
phrases at the end, followed by a paragraph mark(return)

Example:
This color is: Green
This page is Blue
This color is: Red
This color is: Burnt Sienna

I want to be able to globally select lines 1, 3 & 4 and
delete them.
I can't find a wild card that will do that reliably.
Does anyone know the trick.
Thanks
 
Hi Mike,

Use a macro containing the following code:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="This color is: [A-z]{1,}",
MatchWildcards:=True, Wrap:=wdFindContinue, Forward:=True) = True
Selection.Bookmarks("\line").Range.Delete
Loop
End With


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
'This color*^l' <- (thats an lower case Ell, not a One or a vertical line)
will match all the lines you are interested in.

You can also get '^|' by clicking the 'Special' button on the search form
and choosing 'Manual Line Break'

if you do a global replace of that with nothing, it should have the desired
effect.
(Watch out for the very last line, as that may not have a Manual Line Break
at the end, so won't match)

ChrisM
 
use instr() function to get info abt ":"
If that present delete the line..
it a algorithm u can say..

thks n regard
 
Back
Top