I am encountering an error I don't know how to fix. My gut says I need a helper array (new to arrays in general) to achieve this, but maybe someone has a clever alternative.
Info: 'b' array gets its values from division of two array elements in 'a' array
The code below works fine unless I increase the number of calculations and then I get a Procedure too large error. My dataset needs to generate around 1200 columns in array b using this approach. I haven't figured out the syntax to do all the calculations with a loop.
Goal: Be able to make up to 1200 calculations like b(i,1) = a(i,1) / a(i,2) without running into Procedure too large error
Info: 'b' array gets its values from division of two array elements in 'a' array
The code below works fine unless I increase the number of calculations and then I get a Procedure too large error. My dataset needs to generate around 1200 columns in array b using this approach. I haven't figured out the syntax to do all the calculations with a loop.
Goal: Be able to make up to 1200 calculations like b(i,1) = a(i,1) / a(i,2) without running into Procedure too large error
VBA Code:
Option Explicit
Sub test()
Dim lr As Long, a As Variant, b As Variant
Dim i As Long, j As Long
lr = Sheet3.Range("A" & Rows.Count).End(xlUp).row
a = Sheet2.Range("B2:AY" & lr).Value2
ReDim b(1 To UBound(a, 1), 1 To 10)
'##Nested loop to get cell values from array a to array b with a calculation in between
For i = 1 To UBound(a)
' For j = 1 To 50 ## not using j at the moment
b(i, 1) = a(i, 1) / a(i, 2) 'note these calculations are representing non recursive combinations of 5 elements. ie any non repeating combinations of 1 through 5 using two #s.
b(i, 2) = a(i, 1) / a(i, 3) ' I can't figure out how to do this with a loop
b(i, 3) = a(i, 1) / a(i, 4) ' maybe I need some sort of helper array as if I simply put in more calculations like this (~1200)
b(i, 4) = a(i, 1) / a(i, 5) ' eventually the procedure becomes too large even for 64bit.
b(i, 5) = a(i, 2) / a(i, 3)
b(i, 6) = a(i, 2) / a(i, 4)
b(i, 7) = a(i, 2) / a(i, 5)
b(i, 8) = a(i, 3) / a(i, 4)
b(i, 9) = a(i, 3) / a(i, 5)
b(i, 10) = a(i, 4) / a(i, 5)
'Next
Next
Range("B2").Resize(UBound(b, 1), UBound(b, 2)).Value = b
End Sub