1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| Private Sub CalculHeure()
Dim i As Integer
Dim login() As String
Dim logout() As String
Dim hlogin, mlogin, hlogout, mlogout, heurelogin, heurelogout As String
Dim datelogin, datelogout, dureeheure
Set WScible = Worksheets("Résumé")
For i = 2 To WScible.Range("B65536").End(xlUp).Row
With WScible
datelogin = .Range(Cells(i, 2).Address).Value
heurelogin = .Range(Cells(i, 3).Address).Value
login = Split(Format(heurelogin, "[h]:mm"), ":")
datelogout = .Range(Cells(i, 4).Address).Value
heurelogout = .Range(Cells(i, 5).Address).Value
logout = Split(Format(heurelogout, "hh:mm"), ":")
'Coupe heure / minutes
hlogin = login(0)
mlogin = login(1)
hlogout = logout(0)
mlogout = logout(1)
If datelogin = datelogout Then
If hlogout = 0 Then
hlogout = 12
ElseIf hlogin = 0 Then
hlogin = 12
End If
mlogin = mlogin / 60
mlogout = mlogout / 60
hlogin = hlogin + mlogin
hlogout = hlogout + mlogout
dureeheure = hlogout - hlogin
dureeheure = Format(dureeheure, "#0.00")
.Range(Cells(i, 6).Address).Value = dureeheure
'Suppression des login / logout de durée 0
If dureeheure = 0 Then
.Range(Cells(i, 6).Address).EntireRow.Delete
End If
End If
End With
Next i
End Sub |
Partager