When i gets above 15 it needs to go to the next.a = 0 Do While a < nr_comp + 1 base = vtresult(0, a, 0, 1) * 1.005 i = 0 Do While vtresult(i, a, 0, 1) <= base t = vtresult(i, a, 0, 1) If (i <= 15) Then iGo = i - 1 Else iGo = 3333 End If i = i + 1 Loop