Private Sub Workbook_Open()
Dim total As Double
For i = 0 To 30
Dim start As Integer
start = 18
Dim dayTime As String
dayTime = Cells(start + i, 21)
If (Len(dayTime) = 11) Then
Dim startStr As String
startStr = Left(dayTime, 5)
Dim startTime As Date
startTime = CDate(startStr)
Dim endStr As String
endStr = Right(dayTime, 5)
Dim endTime As Date
endTime = CDate(endStr)
If (endTime > CDate("17:30")) Then
endTime = CDate("16:30")
End If
dayTime = Application.WorksheetFunction.Text(endTime - startTime, "h:mm")
Dim minuteStr As String
minuteStr = Right(dayTime, 2)
Dim minuteInt As Integer
minuteInt = CInt(minuteStr)
Dim minuteDouble As Double
If minuteInt - 45 > 0 Then
minuteDouble = 0.75
ElseIf minuteInt - 30 > 0 Then
minuteDouble = 0.5
ElseIf minuteInt - 15 > 0 Then
minuteDouble = 0.25
Else
minuteDouble = 0
End If
Dim hourStr As String
hourStr = Left(dayTime, 1)
Dim hourInt As Integer
hourInt = CInt(hourStr)
Dim dayDouble As Double
dayDouble = hourInt + minuteDouble
total = total + dayDouble
End If
Next i
MsgBox total
End Sub
阅读(1764) | 评论(0) | 转发(0) |