ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   2-dim array into sheet (https://www.excelbanter.com/excel-programming/298149-2-dim-array-into-sheet.html)

fabalicious[_24_]

2-dim array into sheet
 
Hi ya!

Do you know a way to "paste" a 2-dimensional array (calculated in
macro) into a sheet (where one dimension will be rows and another on
columns, obviously...) ?

Help highly appreciated,

Fabaliciou

--
Message posted from http://www.ExcelForum.com


Tushar Mehta

2-dim array into sheet
 
Use something like the tested:

Option Explicit

Function DimensionSize(Arr, Optional whatDim As Integer = 1)
On Error Resume Next
DimensionSize = UBound(Arr, whatDim) - LBound(Arr, whatDim) + 1
End Function
Sub transferDataToXL()
Dim SomeArr(2 To 21, 3 To 12) As Double, _
i As Integer, j As Integer
For i = LBound(SomeArr, 1) To UBound(SomeArr, 1)
For j = LBound(SomeArr, 2) To UBound(SomeArr, 2)
SomeArr(i, j) = i / j
Next j
Next i
Range("a1").Resize( _
DimensionSize(SomeArr, 1), DimensionSize(SomeArr, 2)).Value = _
SomeArr
End Sub

I will leave it up to you to figure out what portions of the above code
were needed for testing and what do the actual work. ;-)



--
Regards,

Tushar Mehta
www.tushar-mehta.com
Multi-disciplinary business expertise
+ Technology skills
= Optimal solution to your business problem
Recipient Microsoft MVP award 2000-2004

In article , fabalicious
says...
Hi ya!

Do you know a way to "paste" a 2-dimensional array (calculated in a
macro) into a sheet (where one dimension will be rows and another one
columns, obviously...) ?

Help highly appreciated,

Fabalicious


---
Message posted from http://www.ExcelForum.com/



Alan Beban[_2_]

2-dim array into sheet
 
fabalicious < wrote:

Hi ya!

Do you know a way to "paste" a 2-dimensional array (calculated in a
macro) into a sheet (where one dimension will be rows and another one
columns, obviously...) ?


Range("A11").Resize(UBound(TwoDarray) - LBound(TwoDarray) + 1, _
UBound(TwoDarray, 2) - LBound(TwoDarray, 2) + 1).Value = TwoDarray

Alan Beban


All times are GMT +1. The time now is 11:44 PM.

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