Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim hdeb As Double, hfin As Double, coldeb As Integer, colfin As Integer
'la ligne ci dessous c'est pour contrôler qu'on est bien dans les bonnes cellules
If Not Intersect(Target, Range("B9:CX12, B17:CX20, B25:CX28, B33:CX36")) Is Nothing Then
If Target.Interior.Color = RGB(225, 150, 225) Then 'pour supprimer une selection
Target.Interior.Color = Cells(Target.Row, 3).Interior.Color
Exit Sub
End If
With Selection
coldeb = .Column
hdeb = ((coldeb - 3) / 4) - 1
If hdeb >= 5 And hdeb <= 21 Then 'si jour +12h
colfin = coldeb + 47: hfin = hdeb + 12
MsgBox Format(hdeb / 24, "hh:mm") & " / " & Format(hfin / 24, "hh:mm")
Else 'sinon +10h
colfin = coldeb + 39: hfin = hdeb + 10
MsgBox Format(hdeb / 24, "hh:mm") & " / " & Format(hfin / 24, "hh:mm")
End If
End With
'couleur
Range(Cells(Target.Row, coldeb), Cells(Target.Row, colfin)).Interior.Color = RGB(225, 150, 225)
End If
End Sub