View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mangesh Mangesh is offline
external usenet poster
 
Posts: 18
Default pasting array output to sheet

No it doesn't. A slight modification:

Set rng = Sheet2.Range("b2")
Range(rng.Address, rng.Offset(m - 1, n - 1).Address) = FinalOutput

- Mangesh



"Alan Beban" wrote in message
...
One way:

Set rng = Sheet2.Range("b2")
Range(rng(1,1),rng(10,15)) = FinalOutput

I didn't test the above, but if your code works, it should work.

Alan Beban

Pradip Jain wrote:
my code generates output in an array of m by n dimensions (m rows and n
columns). Number of rows and columns depends on the input. now i want to
paste the result to sheet2 starting from cell B2. one of the way is as

under:

For ctr15 = 1 To n
For ctr16 = 1 To m
Sheet2.Cells(1 + ctr16, 1 + ctr15).Value = FinalOutput(ctr16, ctr15)
Next ctr16
Next ctr15

This works fine, but the problem is it is too slow. excel paste the

result
cell by cell and is very slow. Much faster code is when entire array is
pasted at a time. assuming 10 rows by 15 column output, code is:

Sheet2.Range("b2:p11") = FinalOutput

This also works. But problem is how to generalize the above code based

on
different values of m and n, i.e. different rows and columns. I tried

the
specifying just the corner left cell of the range, but that does not

works
Sheet2.Range("b2") = FinalOutput
this just returns value on cell b2

please help
regards
pradip