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
| Sub Test()
Dim LastLig As Long, i As Long
Dim LastCol As Integer, j As Integer
Application.ScreenUpdating = False
With Sheets("Feuil1")
LastLig = .Cells(.Rows.Count, "A").End(xlUp).Row
LastCol = .Cells(3, .Columns.Count).End(xlToLeft).Column
For i = 4 To LastLig
For j = 4 To LastCol
If DateDiff("d", .Cells(i, 1).Value, .Cells(1, j).Value) < 0 And DateDiff("d", .Cells(i, 1).Value, .Cells(2, j).Value) > 0 Then
.Cells(i, j).Value = "A"
Else
If DateDiff("d", .Cells(i, 2).Value, .Cells(1, j).Value) < 0 And DateDiff("d", .Cells(i, 2).Value, .Cells(2, j).Value) > 0 Then
.Cells(i, j).Value = "B"
Else
If DateDiff("d", .Cells(i, 3).Value, .Cells(1, j).Value) < 0 And DateDiff("d", .Cells(i, 3).Value, .Cells(2, j).Value) > 0 Then
.Cells(i, j).Value = "C"
Else
.Cells(i, j).Value = 0
End If
End If
End If
Next j
Next i
End With
End Sub |
Partager