#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default array copy

Hello!
I have a very big array and I want to make a copy of it under a different
name.
Right now I am doing it by "muscle", but is there a faster, simpler way of
doing it?
This is the code I am using right now. I want to copy MatrizDatos into
MatrizMovimientos.

ReDim MatrizMovimientos(1 To UBound(MatrizDatos, 1), 1 To 12)
For x = 1 To UBound(MatrizMovimientos, 1)
For z = 1 To 12
MatrizMovimientos(x, z) = MatrizDatos(x, z)
Next z
Next x

Thanx,
Albert C
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default array copy

You don't have to loop through like that. Just copy the array.


Dim MatrizMovimientos as Variant
MatrizMovimientos = MatrizDatos

Demonstration code:
Dim x(2, 3) As String
Dim xcopy As Variant

x(0, 0) = "0,0"
x(0, 1) = "0,1"
x(0, 2) = "0,2"
x(0, 3) = "0,3"
x(1, 0) = "1,0"
x(1, 1) = "1,1"
x(1, 2) = "1,2"
x(1, 3) = "1,3"
x(2, 0) = "2,0"
x(2, 1) = "2,1"
x(2, 2) = "2,2"
x(2, 3) = "2,3"


xcopy = x
For i = 0 To 2
Debug.Print xcopy(i, 0)
Next


Ray at work
ASP[.Net] MVP



"Albert" wrote in message
...
Hello!
I have a very big array and I want to make a copy of it under a different
name.
Right now I am doing it by "muscle", but is there a faster, simpler way of
doing it?
This is the code I am using right now. I want to copy MatrizDatos into
MatrizMovimientos.

ReDim MatrizMovimientos(1 To UBound(MatrizDatos, 1), 1 To 12)
For x = 1 To UBound(MatrizMovimientos, 1)
For z = 1 To 12
MatrizMovimientos(x, z) = MatrizDatos(x, z)
Next z
Next x

Thanx,
Albert C



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
copy one array formula to an array range guedj54 Excel Programming 2 October 29th 06 07:38 PM
copy array formula JR573PUTT Excel Worksheet Functions 2 February 16th 06 10:12 PM
copy an array formula JR573PUTT[_3_] Excel Programming 1 February 16th 06 09:11 PM
copy 1 array to another array matelot Excel Programming 4 January 5th 06 07:20 AM
Copy Array pointer rather than entire array R Avery Excel Programming 2 August 24th 04 08:28 PM


All times are GMT +1. The time now is 01:51 AM.

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"