oleppedersen
New Member
- Joined
- Mar 23, 2013
- Messages
- 13
Hi, apologies if this has been answered before, I could not find anything after a long search.
I am running through hundreds of data sets, which I am transforming into new data based on a various numbers of dividends and divisors (D&D for short here).
During each process, I count the number of D&D. Then I open the files and want to move them into an array each.
It is easy defining the range and last row as these are onedimensional data - rT(1) will be one range, rT(2) another etc.
However, when I am ready to redim the array that shall hold the data, I run into problems which may be simple for better coders than me:
Normally, I define an array like this (as an example): (I know there are probably other ways to do this, but for me it is a logical way of keeping track of the arrays I use.)
Dim aT() ' I have also dimmed the array this way now
Set rT = ws.Range("A1:B" & LastRow)
ant = rT.Count ' I always count to make the array an exact size
Redim aT(ant)
aT = rT.Value
But in my current work, I am working with that I presume are multidimensional arrays, so the code is:
Dim aT
...
For x = 1 to NumberOfFiles
set rT(x) = ws(x).Range("A1:B" &LastRow(x))
ant = rT(x).Count
redim aT(x, ant) ' Can this be correct???
aT = rT(x).Value ' Can this be correct???
I realize there is something I am not grasping regarding multidimensional arrays.
As I am working on a huge number of files and a number of arrays all the time - and the numbers change - I would love to understand how the easy to use array function could work out here.
Any suggestions are greatly appreciated.
NB: The code is at the moment around 3.500 lines long and contains loads of errors, so the tests I have run up til this point in the code seems pretty inconclusive.
I am running through hundreds of data sets, which I am transforming into new data based on a various numbers of dividends and divisors (D&D for short here).
During each process, I count the number of D&D. Then I open the files and want to move them into an array each.
It is easy defining the range and last row as these are onedimensional data - rT(1) will be one range, rT(2) another etc.
However, when I am ready to redim the array that shall hold the data, I run into problems which may be simple for better coders than me:
Normally, I define an array like this (as an example): (I know there are probably other ways to do this, but for me it is a logical way of keeping track of the arrays I use.)
Dim aT() ' I have also dimmed the array this way now
Set rT = ws.Range("A1:B" & LastRow)
ant = rT.Count ' I always count to make the array an exact size
Redim aT(ant)
aT = rT.Value
But in my current work, I am working with that I presume are multidimensional arrays, so the code is:
Dim aT
...
For x = 1 to NumberOfFiles
set rT(x) = ws(x).Range("A1:B" &LastRow(x))
ant = rT(x).Count
redim aT(x, ant) ' Can this be correct???
aT = rT(x).Value ' Can this be correct???
I realize there is something I am not grasping regarding multidimensional arrays.
As I am working on a huge number of files and a number of arrays all the time - and the numbers change - I would love to understand how the easy to use array function could work out here.
Any suggestions are greatly appreciated.
NB: The code is at the moment around 3.500 lines long and contains loads of errors, so the tests I have run up til this point in the code seems pretty inconclusive.