Macro find and delete

H

Hans G

Does anyone know how to make a macro that finds a text in a document and
selects from that point tot another point, also seeking.
For example:

In the text below, I want the macro select all the lines from A till (the
first) C and then delete that part, of replace it with.....

Hans

F

B

B

A

C

C

A

B

B

C

B

C

B

D

D

B

D

D

C

C

D

B

C

C

D

C

B

B

D

D

A

C

D

A

C

Z

B
 
D

Dave Lett

Hi Hans,

As long as you're sure that "A" and "C" are unique, then you can use the
following:

With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = "A*C"
.MatchWildcards = True
With .Replacement
.ClearFormatting
.Text = "Replace"
End With
.Execute Replace:=wdReplaceAll
End With
End With

HTH,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top