Sub test()
Application.StatusBar = False
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim r As Long, i As Long, t As Single
t = Timer
With Sheet1
r = .[a65536].End(xlUp).Row
For i = 4 To r
grrq = Int(Application.WorksheetFunctin.Days360(Range("p" & i), Range("r2")) / 30)
.Cells(i, 19) = Round(.Cells(i, 17) * .Cells(i, 18), 2)
.Cells(i, 21) = Round(.Cells(i, 20) * 12, 2)
.Cells(i, 22) = IIf(grrq >= Cells(i, 21), Cells(i, 21), grrq)
.Cells(i, 23) = Round((Cells(i, 18) - Cells(i, 19)) / Cells(i, 21), 0)
If Int(grrq / 30) = Cells(i, 21) Then
.Cells(i, 24) = .Cells(i, 18) - .Cells(i, 19) - .Cells(i, 23) * (.Cells(i, 21) - 1)
Else
If grrq > .Cells(i, 21) Then
.Cells(i, 24) = "已折旧完"
Else
If .Cells(i, 22) <= 0 Then
.Cells(i, 25) = 0
Else
.Cells(i, 24) = .Cells(i, 23)
End If
End If
If grrq >= .Cells(i, 21) Then
.Cells(i, 25) = .Cells(i, 18) - .Cells(i, 19)
ElseIf .Cells(i, 24) = "本月不提" Then
.Cells(i, 25) = 0
Else
.Cells(i, 25) = .Cells(i, 22) * .Cells(i, 24)
End If
End If
.Cells(i, 26) = .Cells(i, 18) - .Cells(i, 25)
Next i
End With
Application.StatusBar = True
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "一共用时:" & Format(Timer - t, "#0.0000") & " 秒", , ""
End Sub