You don't need a loop for this because there's a known mathematical formula for summing numbers from 1 to n, which is T(n) = n(n+1)/2, e.g. sum of all integers from 1 to 10 is T(10) = 10(10+1)/2 = 55.

So if you want to sum all numbers from say, 3 to 10, just do T(10) - T(2) = 55 - 3 = 52.

Also, if you don't want to include the 3 and 10 in the sum then just take them off the answer.

If you really insist on a loop-type thing, then recursion is much neater:

Code:

Function CalcSum(nStart, nEnd)
If nEnd = nStart Then
CalcSum = nStart
Else
CalcSum = nEnd + CalcSum(nStart, nEnd - 1)
End If
End Function