PC Review


Reply
Thread Tools Rate Thread

Big Array from several worksheets

 
 
=?Utf-8?B?QWxiZXJ0?=
Guest
Posts: n/a
 
      19th Jul 2007
Hello!
I have a very large array which has to be filled with the information from
several worksheets.
Thus far, the strategy I use is to Create an independent Array for the info
on each Worksheet, and then I Consolidate the arrays into one (see procedure
below). However, this is a time consuming procedure which takes up to one
minute.
Maybe someone has some advice to do this faster?
I was thinking something in the lines of...

Sub ArrayConsolidator()
Dim ArrayUnion(1 To 40, 1 To 2) As Variant
ArrayUnion(1 to 20,1 to 2)=Range("A1","B20")
ArrayUnion(21 to 40,1 to 2)=Range("A21","B40")
End Sub

This of course, does not work, but the idea is to fill the big array
partially, and thus not having to consolidate it later. Filling the array by
"Brute Force" is not an option, since the sheets have 65,000 X 12 entries
each, and it takes for ever!
Following is the procedure I currently use to consolidate the arrays.
Best regards,
Albert C.

Sub CallArrayConsolidator
call CallArrayConsolidator(Array1, Array2, Array3)
End sub
Sub ArrayConsolidator(ParamArray vArr())

Dim i As Long, j As Long, k As Long
Dim vE As Variant

i = 0
For Each vE In vArr
i = i + UBound(vE, 1)
Next vE

ReDim MatrizMovimientos(1 To i, 1 To TotalFields)

i = 0
For Each vE In vArr
For j = 1 To UBound(vE, 1)
i = i + 1
For k = 1 To TotalFields
MatrizMovimientos(i, k) = vE(j, k)
Next k
Next j
Next vE

End Sub

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      19th Jul 2007
Why not just use

Dim ArrayUnion

ArrayUnion = Application.Transpose(Range("A1:B40"))

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Albert" <(E-Mail Removed)> wrote in message
news:F0EF20DB-9A5B-46BC-A8CB-(E-Mail Removed)...
> Hello!
> I have a very large array which has to be filled with the information from
> several worksheets.
> Thus far, the strategy I use is to Create an independent Array for the
> info
> on each Worksheet, and then I Consolidate the arrays into one (see
> procedure
> below). However, this is a time consuming procedure which takes up to one
> minute.
> Maybe someone has some advice to do this faster?
> I was thinking something in the lines of...
>
> Sub ArrayConsolidator()
> Dim ArrayUnion(1 To 40, 1 To 2) As Variant
> ArrayUnion(1 to 20,1 to 2)=Range("A1","B20")
> ArrayUnion(21 to 40,1 to 2)=Range("A21","B40")
> End Sub
>
> This of course, does not work, but the idea is to fill the big array
> partially, and thus not having to consolidate it later. Filling the array
> by
> "Brute Force" is not an option, since the sheets have 65,000 X 12 entries
> each, and it takes for ever!
> Following is the procedure I currently use to consolidate the arrays.
> Best regards,
> Albert C.
>
> Sub CallArrayConsolidator
> call CallArrayConsolidator(Array1, Array2, Array3)
> End sub
> Sub ArrayConsolidator(ParamArray vArr())
>
> Dim i As Long, j As Long, k As Long
> Dim vE As Variant
>
> i = 0
> For Each vE In vArr
> i = i + UBound(vE, 1)
> Next vE
>
> ReDim MatrizMovimientos(1 To i, 1 To TotalFields)
>
> i = 0
> For Each vE In vArr
> For j = 1 To UBound(vE, 1)
> i = i + 1
> For k = 1 To TotalFields
> MatrizMovimientos(i, k) = vE(j, k)
> Next k
> Next j
> Next vE
>
> End Sub
>



 
Reply With Quote
 
=?Utf-8?B?QWxiZXJ0?=
Guest
Posts: n/a
 
      19th Jul 2007
Hey Bob.
I would, but in reality, the ranges are in different sheets.

"Bob Phillips" wrote:

> Why not just use
>
> Dim ArrayUnion
>
> ArrayUnion = Application.Transpose(Range("A1:B40"))
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Albert" <(E-Mail Removed)> wrote in message
> news:F0EF20DB-9A5B-46BC-A8CB-(E-Mail Removed)...
> > Hello!
> > I have a very large array which has to be filled with the information from
> > several worksheets.
> > Thus far, the strategy I use is to Create an independent Array for the
> > info
> > on each Worksheet, and then I Consolidate the arrays into one (see
> > procedure
> > below). However, this is a time consuming procedure which takes up to one
> > minute.
> > Maybe someone has some advice to do this faster?
> > I was thinking something in the lines of...
> >
> > Sub ArrayConsolidator()
> > Dim ArrayUnion(1 To 40, 1 To 2) As Variant
> > ArrayUnion(1 to 20,1 to 2)=Range("A1","B20")
> > ArrayUnion(21 to 40,1 to 2)=Range("A21","B40")
> > End Sub
> >
> > This of course, does not work, but the idea is to fill the big array
> > partially, and thus not having to consolidate it later. Filling the array
> > by
> > "Brute Force" is not an option, since the sheets have 65,000 X 12 entries
> > each, and it takes for ever!
> > Following is the procedure I currently use to consolidate the arrays.
> > Best regards,
> > Albert C.
> >
> > Sub CallArrayConsolidator
> > call CallArrayConsolidator(Array1, Array2, Array3)
> > End sub
> > Sub ArrayConsolidator(ParamArray vArr())
> >
> > Dim i As Long, j As Long, k As Long
> > Dim vE As Variant
> >
> > i = 0
> > For Each vE In vArr
> > i = i + UBound(vE, 1)
> > Next vE
> >
> > ReDim MatrizMovimientos(1 To i, 1 To TotalFields)
> >
> > i = 0
> > For Each vE In vArr
> > For j = 1 To UBound(vE, 1)
> > i = i + 1
> > For k = 1 To TotalFields
> > MatrizMovimientos(i, k) = vE(j, k)
> > Next k
> > Next j
> > Next vE
> >
> > End Sub
> >

>
>
>

 
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
Two worksheets, one array =?Utf-8?B?Ym9i?= Microsoft Excel Misc 2 14th Jun 2006 11:26 PM
Array to Worksheets Paul W Smith Microsoft Excel Programming 2 16th Mar 2006 08:29 PM
printing an array of worksheets =?Utf-8?B?TWFyY28gZGUgV2l0dGU=?= Microsoft Excel Misc 4 8th Dec 2004 03:21 PM
For....Next- Array of worksheets. Julian Milano Microsoft Excel Programming 5 15th Dec 2003 01:09 PM
array worksheets GUS Microsoft Excel Programming 1 23rd Sep 2003 03:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:27 AM.