Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I transpose nXm matrix to mXn Matrix MIHir Excel Worksheet Functions 2 August 9th 08 11:44 AM
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
copy matrix (diagonal) Mut[_8_] Excel Programming 2 May 19th 06 02:52 AM
copy range on every worksheet (diff names) to a master worksheet (to be created) Bernie[_2_] Excel Programming 2 September 22nd 04 03:30 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"