ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Writing Single Dimension Array to Active Sheet (https://www.excelbanter.com/excel-programming/332679-writing-single-dimension-array-active-sheet.html)

Fid[_2_]

Writing Single Dimension Array to Active Sheet
 
I have a single dimension array DataHolder(CellCount) where CellCount =
the number of items in the array.

I want to write the entire contents of the array to C1002 to Cxxxx on
the active sheet where xxxx depends on the length of the array.

I have tried

Range(Cells(1002, 3), Cells(1002 + cellcount, 3)) = DataHolder

but it writes the only value at DataHolder(1) in every cell instead of
all the values in the array.

What am I doing wrong?

Thanks,

Brent


Jake Marx[_3_]

Writing Single Dimension Array to Active Sheet
 
Hi Brent,

Fid wrote:
I have a single dimension array DataHolder(CellCount) where CellCount
= the number of items in the array.

I want to write the entire contents of the array to C1002 to Cxxxx on
the active sheet where xxxx depends on the length of the array.

Range(Cells(1002, 3), Cells(1002 + cellcount, 3)) = DataHolder

but it writes the only value at DataHolder(1) in every cell instead of
all the values in the array.


If you use Application.Transpose to transpose your array, it should work:

Range(Cells(1002, 3), Cells(1002 + cellcount, 3)) = _
Application.Transpose(DataHolder)

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

Alan Beban[_2_]

Writing Single Dimension Array to Active Sheet
 
Fid wrote:
I have a single dimension array DataHolder(CellCount) where CellCount =
the number of items in the array.

I want to write the entire contents of the array to C1002 to Cxxxx on
the active sheet where xxxx depends on the length of the array.

I have tried

Range(Cells(1002, 3), Cells(1002 + cellcount, 3)) = DataHolder

but it writes the only value at DataHolder(1) in every cell instead of
all the values in the array.

What am I doing wrong?

Thanks,

Brent

Try

Range(Cells(1002, 3), Cells(1002 + cellcount - 1, 3)) = _
Application.Transpose(DataHolder)

Alan Beban


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

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