View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default copy 1 array to another array

Just to add, for all versions incl. XL97 declare the target variable as a
non-array variant. In Tushar's demo change -

Dim Arr1(2), Arr2()

to
Dim Arr1(2), Arr2

Regards,
Peter T


"Tushar Mehta" wrote in message
om...
With VB6 (XL2000 or later), use array1=array2, though the target array
cannot be dimensioned.

Option Explicit
Option Base 0

Sub testArrays()
Dim Arr1(2), Arr2()
Arr1(0) = 1: Arr1(1) = 2: Arr1(2) = 3
Arr2 = Arr1
MsgBox Arr2(2)
End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Is there a function in VBA that will allow me to copy from 1 array to
another. I know that I can loop throught each element and assign 1 array

to
the other. But I want to know if there's a faster way such array1 =

array2.
Assume they both have the same size.

Thanks
M