How does .offset(i, counter) work?

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

Mike

Hi everypne,

How does the following piece of code work:

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

In particular the offset line please!

Thanks,
Mike
 
Mike
The With/End With construct says that cell G2 is the reference cell.
The ".Offset(i, ModelCounter)" says "the cell that is "i" rows down and
"ModelCounter" columns to the right (if ModelCounter is positive) from G2.
HTH Otto
 
With Range("G2")
For i = 1 To 30
.Offset(i, ModelCounter) = Range("Picked").Cells(i)
Next
End With


The above script enters data into cell G2 + i rows + ModelCounte
columns

And gets data from the range "Picked", cell number i.

So basically, it goes down the 30 rows according to i, taking the i't
cell from "Picked" and puts it in G2 + ModelCounter columns and
rows.

So if ModelCounter is 4, it will start in K3, K4, K5 .....
 
Dspencer,

As a follows up on the last line of your reply, say I want it to start
in K2 instead of K3,

What change should I make?

Thanks alot in advance,
Mike
 
Back
Top