I have written the following code to test the efficiency of 3 different user definded functions and for some reason it is not performing as expected. When I slightly modify the code it has somehow accessing the original unedited code. I originally had the variable iptr go from 1 To 5000 to make sure it was working and now I have updated the upper limit of the loop to 1000000 but it is still only going up to 5000. When I step into the code to try and see why it is not working I get an "Expression not defined in context" error message on the Watch for both the I and iptr variables and the code performs as if the upper limit has not been changed from 5000. Any thoughts as to why this is happening?
Code:
Sub Macro1()
Dim dtstart As Date
Dim iptr As Long
Dim I As Integer
For I = 1 To 10
dtstart = Now()
For iptr = 1 To 1000000
Sheets("Sheet1").Cells(1, 1).Value = iptr
Next iptr
Sheets("Sheet1").Cells(I, 13).Value = Now() - dtstart
Next I
End Sub