ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   General question on multidimensional variables (https://www.excelbanter.com/excel-programming/444845-general-question-multidimensional-variables.html)

[email protected]

General question on multidimensional variables
 
I have the following situation:

300+ forecasts
Each forecast is built from one of ~4100 candidate structured formula
Each candidate structured formula has 34 items of data


Any variable that I set up that is 300 x 4100 x 34 runs out of memory.

I've tried creating 34 variables each that are 300 x 4100 but that seem very inefficient.


joeu2004[_2_]

General question on multidimensional variables
 
wrote:
Any variable that I set up that is 300 x 4100 x 34
runs out of memory.


I had no problem executing the following macro:


Sub doit()
Dim v(1 To 300, 1 To 4100, 1 To 34) As Long
Dim n As Long, st As Double
st = Timer
For i = 1 To 300: For j = 1 To 4100: For k = 1 To 34
n = n + 1
v(i, j, k) = i * 1000000 + j * 100 + k
Next k, j, i
MsgBox n & " " & Format(Timer - st, "0.000 sec")
End Sub


The array v consumes 167,280,000 bytes. Task Manager showed that the peak
usage was about 186,968,064 bytes. Note the peak usage for Excel (new
workbook) and VBA (trivial macro) is about 19,402,752. So the numbers are
about right.

The run time was about 10.5 seconds.

Of course, that is for my version of Excel (2003) on my computer. YMMV.




All times are GMT +1. The time now is 01:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com