(Solved) – VBA For Loop stopping early

(solved)-–-vba-for-loop-stopping-early

I wanted to pass through the loop 100 times and stop when a is 101 then go to the next line. However, when it reached 101 the code just stops and does go to the next line. If the for loop is from 1 to 10 is goes to the next line without a problem, but it seems like anything greater than 10 is won’t go to the next line.

Function fint(x As Double) As Double
Dim a As Double, b As Double, c As Double, d As Double, e As Double
Dim sum As Variant, sum1 As Variant, sum2 As Variant, sum3 As Variant
Dim group As Double, group1 As Double, group2 As Double

sum = 0
sum1 = 0
sum2 = 0
sum3 = 0

For a = 0 To 100

sum = sum   (x / 2) ^ (2 * a) / ((WorksheetFunction.Fact(a)) ^ 2 * (2 * a   1))

Next a

group = -1 * (0.5772156649 * WorksheetFunction.Ln(x / 2)) * x * sum

fint = group

End Function

enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *