PC Review


Reply
 
 
=?Utf-8?B?QWxiZXJ0?=
Guest
Posts: n/a
 
      1st Nov 2006
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 With Quote
 
 
 
 
Ray Costanzo [ASP.Net MVP]
Guest
Posts: n/a
 
      1st Nov 2006
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" <(E-Mail Removed)> wrote in message
news:90EFF586-BABE-4C10-B6B4-(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variant Array Copy, Array row contains Object Neal Zimm Microsoft Excel Programming 3 13th Apr 2010 03:21 PM
Fast copy method of sub array (=array range) possible? Thomas Lebrecht Microsoft VB .NET 0 19th Mar 2009 08:49 AM
Array.Copy and Cloning an array don't seem to work differently illegal.prime@gmail.com Microsoft Dot NET Framework 1 29th Aug 2006 12:13 AM
Array.Copy and Cloning an array don't seem to work differently illegal.prime@gmail.com Microsoft C# .NET 1 29th Aug 2006 12:13 AM
select variables ranges, copy to array, paste the array in new workbook Mathew Microsoft Excel Worksheet Functions 1 1st Apr 2005 09:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:32 PM.