MrExcel
.
- Joined
- Feb 8, 2002
- Messages
- 3,417
- Office Version
- 365
- Platform
- Windows
I am working with a home-grown Better Scenario Manager macro. The user can enter a starting value, ending value, and a step value and I loop through the various input values.
While testing, I noticed that this particular set of inputs isn't working
It prints 0.05 but never prints 0.06. If I watch the i variable, it reports 0.06 after the loop, so the floating point comparison of (0.05+0.01) to (0.06) must be stinging me here.
My solution was to add a "little bit" to the MaxV as below. Any other ideas?
Bill
While testing, I noticed that this particular set of inputs isn't working
Code:
For i = 0.05 to 0.06 step 0.01
Debug.Print i
Next i
My solution was to add a "little bit" to the MaxV as below. Any other ideas?
Code:
MinV = cells(i, 4).Value
MaxV = cells(i, 5).Value
StepV = cells(i, 6).value
Maxv = MaxV + StepV / 2
For i = MinV to MaxV Step StepV
' ... Do Stuff
Next i
Bill