ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   (Newbie) Copying values from an array to the worksheet (https://www.excelbanter.com/excel-programming/334271-newbie-copying-values-array-worksheet.html)

Srdjan Kovacevic[_5_]

(Newbie) Copying values from an array to the worksheet
 
The catch is this: the array is 2-dimensional and it's not fixed in size, so
I can't define the worksheet range in advance.

The array is quadratic and its dimension is user defined; i.e.

ReDim varArray(varN, varN) as Integer

varN can be anywhere from 100 to 500.

Can I copy the contents of this aray to the worksheet just by refering the
anchor cell (i.e. the top-left cell)?

I've tried:

Range("A1").value = varArray

and it just pulls the varArray(1,1) value.

I've also tried

Range("A1").Offset(varN, varN).value = varArray

but the debugger reports an error (he probably doesn't recognize the object
I'm refering to).

please CC: your reply to

srdan.kovacevic(a)fsb.hr

(a) is obviously the monkey-sign (spamspoofer)

Thanks in advance!
srdan



Tom Ogilvy

(Newbie) Copying values from an array to the worksheet
 
rws = Ubound(varArray,1)-Lbound(varArray,1)+1
cls = Ubound(varArray,2) - Lbound(varArray,2) + 1
Range("A1").Resize(rws,cls) = varArray

--
Regards,
Tom Ogilvy

"Srdjan Kovacevic" wrote in message
...
The catch is this: the array is 2-dimensional and it's not fixed in size,

so
I can't define the worksheet range in advance.

The array is quadratic and its dimension is user defined; i.e.

ReDim varArray(varN, varN) as Integer

varN can be anywhere from 100 to 500.

Can I copy the contents of this aray to the worksheet just by refering the
anchor cell (i.e. the top-left cell)?

I've tried:

Range("A1").value = varArray

and it just pulls the varArray(1,1) value.

I've also tried

Range("A1").Offset(varN, varN).value = varArray

but the debugger reports an error (he probably doesn't recognize the

object
I'm refering to).

please CC: your reply to

srdan.kovacevic(a)fsb.hr

(a) is obviously the monkey-sign (spamspoofer)

Thanks in advance!
srdan






All times are GMT +1. The time now is 07:40 AM.

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