I tried the function in post #8, but it didn't get very far. When I tried it, it errored on the first arr=rdata line, so I am not recreating what you are seeing. In this respect, I am seeing the same thing karedog is seeing.
A declaration like dim arr() as variant looks to me like a dynamic array of variants. You never declare how many elements to declare for arr(), which, I think causes it to error when it tries to assign something to the incompletely defined array.
If I add a ReDim statement before the assignment statement
it successfully assigns the range of values to an array arr(0)(i,j) -- now we have an array of arrays. Later syntax does not account for this, so there are errors later in the code.
Removing the array part of the declaration
works just fine, and arr becomes a variant containing an array.
I think what I see causing confusion here is something that I incompletely understand. You can have a variant that contains an array. You can have an array of variants, and each element in the array of variants may be a variant containing an array (creating the possibility of an array of arrays or a jagged array). Keeping those possibilities straight sometimes challenges me, and I find I must think very carefully through exactly what rData will be and what I want arr to be and the different scenarios I expect to see.
Bookmarks