How to break in the middle of the For / Next loop.

T

Tommy

Hello, I'd like to know how to do it. I have a for/next loop in my macro, I
set the highest number is 100, but most of the time, I don't need to run all
the way to 100, sometimes is 40, sometimes is 83, etc, random number of
records to process using the macro. can you help please? thanks.

Dim i As Integer
For i = 1 To 100
"macro running"
Next i
 
T

Tommy

All records are in the Word document generated by an accounting system. it
contains varies number of records depending on the month. thanks!
 
L

Lynn

How do you read the records in your Word document when running your macro?
Is the data "pushed" to Word or are you "pulling" the data? It sounds like
it might be a push...but I'm not sure.
....just trying to get a full picture of the scenario.
 
L

Lynn

Tommy,
If you can determine the number of records upfront, then you can store that
value in a variable (intNumOfRecs). Next, you can base the For...Next loop on
the information retrieved.
Something like this:

Dim intNumOfRecs as Integer

For i = 1 To intNumOfRecs
"macro running"
Next i

I probably need more information in order to help you, but this might give
you an idea.
 

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