'how to write from an array in Access to an Excel Range

I have a data structure (array) in Access - 6 columns and 10 rows.

I'm trying to write to a range in Excel ie B3:G12.

I'm getting tied up in loops, literally.

For j = 0 to ubound(varArray,1)

     For i = 0 to ubound(varArray)

          For each xlCell in wksheet.range("B3:G12")

               xlCell.Value = varArray(i,j)

          Next xlCell

     Next i

Next j

This I'm struggling with as the 2 loops work in different ways. The xlCell loop goes across and then down.

The array loop also goes across but then we switch lanes as it were.

I can't get the xlCell loop to advance at all.

Can someone help?

tintedsepia



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source