Problem with Loops

chrgrose

Board Regular
Joined
Sep 11, 2009
Messages
80
Code:
Sub runner()
Dim a As Long

For a = 1 To 12 Step 1
  "Do something"
  Loop
Next a

End Sub
How do this task 100 times without repeating the whole "For..." code? Right now I have a sheet like this and the only way I can keep it running is if I manually run it over and over. I've tried to nest this loop in another loop but it acts like it can't redo the loop if it's already been performed.
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
It's hard to say without seeing the actual code you're trying to use, and not a simplified example.

Are you trying to do a loop within a loop?

Try something like

Rich (BB code):
For a = 1 to 12
   'This line is executed only 12 times (each loop of a)
    For b = 1 to 100
       'This line is executed a total of 1200 times
       '100 loops of b X 12 loops of a
    Next b
Next a
 

Watch MrExcel Video

Forum statistics

Threads
1,122,216
Messages
5,594,886
Members
413,947
Latest member
gizmolucy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top