The VBA Variant
is pretty flexible, and you can use it to do what you want, but not to do exactly what you're asking. They key is to ditch the 3-D array and instead use an array that contains other arrays.
I might be rearranging the meaning of your indices here, but consider something like this:
Dim china
china = [china!Q42:X99]
Dim india
india = [india!Q42:X99]
...
Dim world(1 to 242)
world(1) = china
world(2) = india
...
[report!Q42:X99] = world(42)
This example uses a 1-D array of Variant
s, each element of which is a 2-D array of Variant
s that comes from various Excel ranges. If you can think of a 3-D array as a cube, think of this structure as a (1-D) book of (2-D) pages.
Normally, messing with data using only arrays (nested or otherwise) can be fraught with peril. However, in VBA code supporting an Excel spreadsheet it can often be the most natural way to do things. It's possible to define Type
s and Class
es in VBA, but many times that's overkill because both the source of your data and the final results of your calculation are just 2-D ranges on a worksheet somewhere.
Here are some relevant earlier answers of mine to related questions:
VBA pasting 3 dimensional array into sheet
How can I "ReDim Preserve" a 2D Array in Excel 2007 VBA so that I can add rows, not columns, to the array?