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.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,160
Messages
5,835,725
Members
430,383
Latest member
Kastore

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