ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Write 3d array to range (https://www.excelbanter.com/excel-programming/380293-write-3d-array-range.html)

[email protected]

Write 3d array to range
 
Hi,

I have an array defined as:
Dim team_vs_team_array(15, 15, 5)

Through code I populate each value within the array reading from
various worksheets, and completing calculations along the way (each
value is an integer).
Through the Watch function in VBA, I can confirm that the array is
holding the data the way I expect.

How can I accomplish the following:
Worksheets("temp").range("c4:ct19") = team_vs_team_array


I have been reading he archived messages, and thus far have not been
able to come up with a solution that fits my problem.

I am working in XL2003.

thanks in advance.


Nigel

Write 3d array to range
 
You need to loop the values to assign the 3D array to a 2D range

something like.......

Dim i As Integer, j As Integer, k As Integer
For i = 0 To 5
For j = 1 To 16
For k = 1 To 16
Cells(k + 3, j + 2 + i * 16) = team_vs_team_array(k - 1, j - 1, i)
Next
Next
Next



--
Cheers
Nigel



wrote in message
ups.com...
Hi,

I have an array defined as:
Dim team_vs_team_array(15, 15, 5)

Through code I populate each value within the array reading from
various worksheets, and completing calculations along the way (each
value is an integer).
Through the Watch function in VBA, I can confirm that the array is
holding the data the way I expect.

How can I accomplish the following:
Worksheets("temp").range("c4:ct19") = team_vs_team_array


I have been reading he archived messages, and thus far have not been
able to come up with a solution that fits my problem.

I am working in XL2003.

thanks in advance.




Dave[_71_]

Write 3d array to range
 

Thanks Nigel,

I had to tweak the cell assignment slightly but that was definitely the
key to the solution.

Dave

On Dec 31, 12:33 am, "Nigel" wrote:
You need to loop the values to assign the 3D array to a 2D range

something like.......

Dim i As Integer, j As Integer, k As Integer
For i = 0 To 5
For j = 1 To 16
For k = 1 To 16
Cells(k + 3, j + 2 + i * 16) = team_vs_team_array(k - 1, j - 1, i)
Next
Next
Next

--
Cheers
Nigel

wrote in oglegroups.com...

Hi,


I have an array defined as:
Dim team_vs_team_array(15, 15, 5)


Through code I populate each value within the array reading from
various worksheets, and completing calculations along the way (each
value is an integer).
Through the Watch function in VBA, I can confirm that the array is
holding the data the way I expect.


How can I accomplish the following:
Worksheets("temp").range("c4:ct19") = team_vs_team_array


I have been reading he archived messages, and thus far have not been
able to come up with a solution that fits my problem.


I am working in XL2003.


thanks in advance.




All times are GMT +1. The time now is 09:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com