View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Application.Caller

just this portion:

As a matter of interest, John uses this line to populate an array :

For i = 1 To Cnt
Ops(i) = Range("Animals").Range("A1").Offset(i - 1, 0)
Next i

I know what is happening, but I can't work out the exact mechanism. Can
you help, please?


Some place in John's sample code are more lines:

dim i as long
dim Cnt as long
dim ops() as variant

cnt = range("animals").cells.count
'I'm assuming a single area, single column range (like B12:B21)

redim ops(1 to cnt) 'make ops have cnt elements--same as the number of
'cells in Range("animals")

for i = 1 to cnt
ops(i) = range("animals").range("a1").offset(i-1,0)
next i

The top left cell in the range("animals") can be refered to as:
range("animals").range("a1")

Range("animals").range("b2")
is one down and one to the right from that topleftcell.

When you do the offset bit, the first time through, i = 1.

..offset(1-1,0) is the same as .offset(0,0)
which is that first cell in the range.
and stuff it into ops(1)

Second time through:
..offset(2-1,0) is .offset(1,0)
means come down one row but stay in the same column
And plop that into ops(2)

And so forth.


Mark Worthington wrote:

<<snipped
--

Dave Peterson