How to repeat a Macro multiple times?

  • Thread starter Thread starter Jeff Mills
  • Start date Start date
J

Jeff Mills

I get a document from a client for publishing every month that's often 30+
pages long, and includes two tabbed columns (a dollar amount field and and a
date field) for a long list of donations that I have to globally delete.
I've created a macro that searches for a TAB then goes to the end of the
line and DELETES everything selected. Beautiful.

How, though, do I instruct Word to now perform that Macro seven or eight
HUNDRED times so that it captures and deletes ALL such instances?

I used to use a word processor (no longer supported) that you could instruct
to perform a macro (or any operation) a certain number of times; I'd enter
700, hit the keystroke for the macro, and away it would go, performing the
macro 700 times. There does not seem to be such an option in Word.

I'm using Word for Mac 11.2, but the concept should apply to any recent
version of Word.

Can you help?

THANK YOU!
 
You should be able to add something like:
Dim strCount As String
Dim lngCount As Long
Dim lngCycle As Long
strCount = InputBox("How many times to repeat?")
lngCount = strCount

For lngCycle = 1 To lngCount
' Your Code Here
Next lngCycle

HTH
Ed
 
The following will probably do what you want:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="^t", MatchWildcards:=False,
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Paragraphs(1).Range.Delete
Loop
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
 
Back
Top