Hi kosherboy,
No problem. Unfortunately I don't remember the website(s) that teach about this. I learned and collected this info from so many places, so I don't remember all of
them, sorry. But I am sure that if you googling using keywords like "Excel VBA array operations" you will get many of them.
One thing that could lead into confusion is maybe lbound() and ubound() function.
lbound() <lower bound> is to get index of the lowest member of the matrix while
ubound() <upper bound> is to get index of the higher member of the matrix
For example, a code like this :
You will get the lbound of the matrix is 3 and ubound of the matrix is 7.
This is an example for one dimension matrix.
Now the example for 2 dimensions matrix :
Since this is a multidimensional matrix, we must tell Excel which dimension we want to examine, by passing the dimension number to second argument of the function.
So for the first the example, it can actually be written as :
but since this is a one dimensional matrix, we can neglect the second argument completely.
Now about the lower bound values, if we don't specifically defined the lower bound value, Excel will start this from 0 or 1. By default it is start with 0 except you
use statement Option Base 1, this will start the lower bound value from 1.
And now about index in Excel range. Please fill some values in range A1:B2
The first line will produce the value of cell A1 while the second line will produce value of cell B2. So the index rule is different for cells property with offset
property (although both is filled with the same values that is (1,1) ).
When we assign a range to a matrix, the rule that used is cell's rule, so the first member of matrix will get index (1,1) <not offset's rule which is (0,0)>.
So now you have already know, that there is different value (it is exactly 1) when working with cells and working with offset.
Now we apply this to your problem :
You assign the LeftCell3 variable, seven cells to left from currenct cell, USING OFFSET METHOD.
Now this one,
You try to assign a value to matrix (which is USE CELL's RULE instead of offset's rule), but you pass the "7" value, while actually it must be "8".
Because you have already know the differences between offset's rule and cell's rule, so it must be clear enough for you now.
Sorry for the long post.
Regards
Bookmarks