Increase Integer by 5 each loop

randolphoralph

Board Regular
Joined
Dec 24, 2008
Messages
126
I am trying to figure out how to rewrite the macro below so that when the loop runs the Integer i increases by 5

So here is what I am looking for the loop to do...

1st loop i = 0
2nd loop i = 5
3rd loop i = 10
4th loop i = 15
5th loop i = 20


Here is the current macro

Code:
Private Sub CommandButton1_Click()
    Dim i As Integer
    For i = 0 To 20:             
        Range("C1").Value = i   
        Application.Calculate
        Sleep 500
    Next
End Sub
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Glad to help, thanks for the feedback..



As an aside, you can also make it go backwards.

For i = 20 To 0 Step -5

That can come in handy..
 

Watch MrExcel Video

Forum statistics

Threads
1,122,719
Messages
5,597,733
Members
414,170
Latest member
Mdm

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