Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Efficiently moving data between worksheets and VBA array variables
I need to move data to and from a worksheet quickly.
The first code segment efficiently moves data from a VBA array to the worksheet. However, going the other way, the second code doesn't work transfering from the sheet to the VBA array. Why doesn't the second example work? Is there an efficient way to transfer data without stepping through a loop? This works: 'Transfer the array to the worksheet starting at cell A2 Dim DATAaRRAY(1 To 100, 1 To 3) As Variant mySheet.Range("A2").Resize(100, 3).Value = DATAaRRAY This doesn't work: 'Transfer from the worksheet to the Array doesn't work. Dim DATAaRRAY(1 To 100, 1 To 3) As Variant DATAaRRAY = mySheet.Range("A2").Resize(100, 3).Value Thanks in advance. Fred. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Efficiently moving data between worksheets and VBA array variables
Try declaring DataArray like:
Dim DATAaRRAY As Variant dataarray = mysheet.range("a2").resize(100,3).value Fred wrote: I need to move data to and from a worksheet quickly. The first code segment efficiently moves data from a VBA array to the worksheet. However, going the other way, the second code doesn't work transfering from the sheet to the VBA array. Why doesn't the second example work? Is there an efficient way to transfer data without stepping through a loop? This works: 'Transfer the array to the worksheet starting at cell A2 Dim DATAaRRAY(1 To 100, 1 To 3) As Variant mySheet.Range("A2").Resize(100, 3).Value = DATAaRRAY This doesn't work: 'Transfer from the worksheet to the Array doesn't work. Dim DATAaRRAY(1 To 100, 1 To 3) As Variant DATAaRRAY = mySheet.Range("A2").Resize(100, 3).Value Thanks in advance. Fred. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to efficiently declare variables | Excel Discussion (Misc queries) | |||
efficiently copy values from a Range of cells to an array (in VB.N | Excel Programming | |||
efficiently copy values from a Range of cells to an array (in VB.N | Excel Programming | |||
Efficiently transform variables into range address | Excel Programming | |||
Efficiently transform variables into range address | Excel Programming |