How does this work?

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi everyone,

Say I have this small piece of code:

With Range("G2")
For i = 1 To 30
.Offset(i, ModelCounter) = Range("Picked").Cells(i)
Next
End With

How can this be read please?

Thanks,
Mike
 
This code fills SOME cells in rows 3:32 with the corresponding values
of another range, which was named Picked.
The function Range("G2").Offset(1,3) returns a reference to a cell 1
row below and three columns to the right. Your code snippet does not
show what is the value of variable ModelCounter, so I don;t know in
which column you offset.
The loop

For i = 1 to 30
....
Next

makes i get progressively the values from 1 to 30. Whatever appears
inside the loop will be executed 30 times, with i each time having been
incremented by 1.

Similarly, Range("Picked").Cells(i) will get one more cell from the
range called Picked.

HTH
Kostis Vezerides
 

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

Similar Threads

How does .offset(i, counter) work? 4
VBA question!? 3
VBA code question? 1
VBA code question?! 1
Clearing ".csv" file using VBA 5
Array Formula 11
Modify code 2
Macro change problem 3

Back
Top