|
本帖最后由 840205910 于 2012-9-8 18:02 编辑
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Row > 1 Then
For i = 2 To [a65536].End(3).Row
If Cells(i, 4) < Cells(i, 3) And Cells(i, 4) <> "" Then Cells(i, 4) = Cells(i, 4) + 1
Range("e" & i & ":g" & i).ClearContents
If Cells(i, 2) = "星期日" And Cells(i, 4) <> "" And Cells(i, 3) <> "" Then
If Cells(i, 4) - Cells(i, 3) > 0.375 Then Cells(i, 6) = (Cells(i, 4) - Cells(i, 3) - 0.375) * 24
If Cells(i, 4) - Cells(i, 3) < 0.375 Then Cells(i, 7) = (Cells(i, 3) - Cells(i, 4) + 0.375) * 24
Else
If Cells(i, 4) <> "" And Cells(i, 3) <> "" And Cells(i, 4) - Cells(i, 3) > 0.375 Then Cells(i, 5) = (Cells(i, 4) - Cells(i, 3) - 0.375) * 24
If Cells(i, 4) <> "" And Cells(i, 3) <> "" And Cells(i, 4) - Cells(i, 3) < 0.375 Then Cells(i, 7) = (Cells(i, 3) - Cells(i, 4) + 0.375) * 24
End If
Next
End If
End Sub
|
|