Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
copy matrix to worksheet
Hi!
I have a two-dimensionnal matrix and i would like copy the contents of this matrix directly to the cells in a worksheet without iterating over each cell one by one. Is this possible? Anyone out there that knows? Thanks! /MÃ¥ns TÃ¥nneryd |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
copy matrix to worksheet
If by "matrix" you mean a range of cells on a worksheet, you can use code like the following: Dim Matrix As Range Dim Dest As Range Set Matrix = Range("B4:C7") '<<< CHANGE AS REQUIRED Set Dest = Range("F10") '<<< CHANGE AS REQUIRED Matrix.Copy Destination:=Dest This copies the range B4:C7 to a range starting at F10. If by "matrix" you mean a 2 dimensional array, you can use code like the following: Dim Matrix(1 To 2, 1 To 2) As Long Dim R As Long Dim C As Long ' load up test values Matrix(1, 1) = 11 Matrix(1, 2) = 22 Matrix(2, 1) = 33 Matrix(2, 2) = 44 ' get number of rows and columns R = UBound(Matrix, 1) - LBound(Matrix, 1) + 1 C = UBound(Matrix, 2) - LBound(Matrix, 2) + 1 ' resize the destination range Range("F10").Resize(R, C).Value = Matrix This writes the contents of the Matrix array to cell F10. Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Thu, 12 Feb 2009 06:40:16 -0800, Måns Tånneryd wrote: Hi! I have a two-dimensionnal matrix and i would like copy the contents of this matrix directly to the cells in a worksheet without iterating over each cell one by one. Is this possible? Anyone out there that knows? Thanks! /Måns Tånneryd |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I transpose nXm matrix to mXn Matrix | Excel Worksheet Functions | |||
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 | Excel Worksheet Functions | |||
copy matrix (diagonal) | Excel Programming | |||
copy range on every worksheet (diff names) to a master worksheet (to be created) | Excel Programming | |||
Code to copy range vs Copy Entire Worksheet - can't figure it out | Excel Programming |