Count backwards with a for next loop

G

Gus Chuch

Don’t you count backwards with a for next loop using the following
For i = 1 To 4
Sheet1.Cells(i, 1) = i
Next i
I cant’ seem to get it to work. I also tried using a Step -1 but no luck
Any ideas ?
 
J

John Bundy

I think what you are wanting would be a for i = 4 to 1 step - 1
you were trying to step backward but increment at the same time.
 
J

Jim May

Step -1 is the route!!
but you may need something like:

Sub tester()
With ActiveSheet
For i = 4 To 1 Step -1
Sheets("Sheet1").Cells(i, 1) = i
Next i
End With
End Sub
 

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