Please help me understand where my syntax is wrong here! I'm a beginner in vba but am learning fast. I'll try to simplify the problem below.
I have created an array called myArray(). It has 5 values, 1,2,3,4, and5. I've confirmed the array was created successfuly. I then have a loop where h is equal to 5 to start:
Do While h > 0
dExpMean = Exp(-dMean)
dFact = 1
dPowr = 1
Do While dCDF < myArray(h)
dCDF = dCDF + dExpMean * dPowr / dFact
iX = iX + 1
dFact = dFact * iX
dPowr = dPowr * dMean
Loop
ReDim Preserve PoisArray(h)
PoisArray(h) = iX - IIf(dCDF / myArray(h) > 1.000000000001, 2, 1)
h = h - 1
Loop
when stepping through the code, it makes it to the highlighted line in red, and then begins to jump back up to higher code lines not shown here. I've input the number 5 instead of "myArray(h)", and the code works fine and steps into the nested loop. It appears that it doesn't like using the array reference as a condition in the nested loop. Is this a limitation? Any ideas on how to make it work? Any help is most appreciated.
I have created an array called myArray(). It has 5 values, 1,2,3,4, and5. I've confirmed the array was created successfuly. I then have a loop where h is equal to 5 to start:
Do While h > 0
dExpMean = Exp(-dMean)
dFact = 1
dPowr = 1
Do While dCDF < myArray(h)
dCDF = dCDF + dExpMean * dPowr / dFact
iX = iX + 1
dFact = dFact * iX
dPowr = dPowr * dMean
Loop
ReDim Preserve PoisArray(h)
PoisArray(h) = iX - IIf(dCDF / myArray(h) > 1.000000000001, 2, 1)
h = h - 1
Loop
when stepping through the code, it makes it to the highlighted line in red, and then begins to jump back up to higher code lines not shown here. I've input the number 5 instead of "myArray(h)", and the code works fine and steps into the nested loop. It appears that it doesn't like using the array reference as a condition in the nested loop. Is this a limitation? Any ideas on how to make it work? Any help is most appreciated.