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
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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..
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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
Back
Top