ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to import a 2-d array into excel using vba? (https://www.excelbanter.com/excel-programming/371366-how-import-2-d-array-into-excel-using-vba.html)

Krussell172

how to import a 2-d array into excel using vba?
 
Hi, I am writing a macro in excel and I have created a 2-d array, populated
it with data, and I want to take the data from the array and put it into an
excel worksheet. I have a loop that gets each array element an puts the data
in a cell. Since my array contains a lot of data, using the loop takes a
while to put the data into the worksheet. This macro is used to update
worksheets in about 100 workbooks, so you see how I would need to optimize
this as much as possible.

Any help would be greatly appreciated.

Krussell

Tom Ogilvy

how to import a 2-d array into excel using vba?
 
assume the array is named ar

dim rwcnt as long, colcnt as long
rwcnt = ubound(ar,1) - lbound(ar,1) + 1
colcnt = ubound(ar,2) - lbound(ar,2) + 1

range("B9").Resize(rwcnt,colcnt).Value = ar

--
Regards,
Tom Ogilvy


"Krussell172" wrote:

Hi, I am writing a macro in excel and I have created a 2-d array, populated
it with data, and I want to take the data from the array and put it into an
excel worksheet. I have a loop that gets each array element an puts the data
in a cell. Since my array contains a lot of data, using the loop takes a
while to put the data into the worksheet. This macro is used to update
worksheets in about 100 workbooks, so you see how I would need to optimize
this as much as possible.

Any help would be greatly appreciated.

Krussell



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

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