Private Sub Worksheet_Change(ByVal Modif As Range)
Dim x As Integer, y As Integer, z As Integer
Dim e As String, f As String
Dim d3 As Date, d4 As Date
Dim Cellule As Range
Dim toto As Range
x = Modif.Row
d3 = Cells(x, 4).Value
d4 = Cells(x, 6).Value
If d3 = 0 Or d4 = 0 Then
Exit Sub
Else
For y = 6 To 400
If Worksheets("Quanti").Cells(y, 3).Value = d3 Then
e = Worksheets("Quanti").Cells(y, 3).Address
End If
If Worksheets("Quanti").Cells(y, 3).Value = d4 Then
f = Worksheets("Quanti").Cells(y, 3).Address
End If
Next
new_plage = Worksheets("Quanti").Range(e, f).Address
MsgBox (new_plage)
End If
For z = 5 To 65
If Worksheets("Quanti").Cells(2, z).Value = Cells(x, 1).Value Then
[COLOR="Red"]For Each Cellule In old_plage[/COLOR]
If Not Intersect(Cellule, new_plage) Is Nothing Then
Cellule.Offset(0, z - 3).Value = "0"
End If
Next Cellule
For Each Cellule In new_plage
If Cells(x, 5).Value = "Matin" Then
Cellule.Offset(0, z - 3).Value = "1"
Else:
Cellule.Offset(0, z - 3).Value = "0,5"
End If
If Cells(x, 7).Value = "Matin" Then
Cellule.Offset(0, z - 3).Value = "0,5"
Else:
Cellule.Offset(0, z - 3).Value = "1"
End If
Next
End If
Next
End Sub