献丑了 得一分 Option Explicit Dim Rng As Range Sub iQeQ() Dim k As Integer Dim i As Integer Set Rng = Sheet1.Range("a1:a10") i = 10 k = 0 Do Until i = 0 i = 0 shftIt i k = k + 1 Loop MsgBox (k - 1) & " times to value:" & Range("a1") End Sub Sub shftIt(i As Integer) Dim cel As Range Dim Ncel As Range Dim valOld As Integer Dim valTmp As Integer valOld = Rng.Cells(1) / 2 For Each cel In Rng Set Ncel = cel.Offset(1, 0) If Ncel.Row > 10 Then Set Ncel = Rng.Cells(1) valTmp = Ncel.Value / 2 Ncel = valTmp + valOld valOld = valTmp If Ncel Mod 2 Then Ncel = Ncel + 1 If valOld * 2 <> Ncel.Value Then i = i + 1 Next End Sub |