In the code, each of the ranges is of length 8, filled with double values. For this test they are either 0 a 2 digit decimal. The test hangs executing the 1st line in the loop. I tested Max and it equals 8. The 1st debug.print:Debug.Print I, O(I, 1), E(I, 1), L(I, 1)
seems to print out correctly: 1 0 0.4 0.2
although I don't fully understand what's happening in the print out [why does it repeat 3 times?]: 1 0 0.4 0.2
1
1 0 0.4 0.2
1
1 0 0.4 0.2
1
Function sniff(core As Double, lim As Double, Baser As Range, Extra As Range, Opn As Range, _
Clse As Range, Last As Range, Preset As Range, ndx As Integer) As Double
Dim MAX As Integer, sum As Double, num As Integer, I As Integer, scal As Double
Dim doit(8)
Dim B()
Dim E()
Dim O()
Dim C()
Dim L()
Dim P()
MAX = Baser.Rows.Count
B = Baser
E = Extra
O = Opn
C = Clse
L = Last
P = Preset
sum = core
num = 0
For I = 1 To MAX
num = num + 1
Debug.Print I, O(I, 1), E(I, 1), L(I, 1)
If O(I, 1) = 1 Then doit(I) = E(I, 1) Else doit(I) = L(I, 1)
' If C(I, 1) = 1 Then
' If P(I, 1) > 0 Then doit(I) = minf(doit(I), P(I, 1)) Else doit(I) = 0
' End If
Debug.Print num
sum = sum + doit(I)
Next I
Debug.Print sum
Bookmarks