CustomX
CustomX

Reputation: 10113

Excel macro - for loop increment

I've looked but can't find a solution.

How do you increment a variable? Like in any other language you just do ++(variable name) just before the end of the loop. In my example, I'd like to increment J.

Dim j as integer
j = 13
FinalRow = Range("B15").End(xlUp).Row
        For i = 9 To FinalRow
            Range("B" & i).Copy Destination:=Sheets("Design").Range("A" & j)
            J++
        Next i

The code loops from B9-B15 and pastes the information in the Designsheet from A13 and downwards.

Upvotes: 2

Views: 32938

Answers (1)

Ben
Ben

Reputation: 35613

Just do this:

J = J + 1

Simples.

Upvotes: 6

Related Questions