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
| Sub test()
Dim DerLigne As Long, Plage As Range, C As Range, C2 As Range, Tabl() As String
Dim Ctr As Integer, Dat As String, Filtre As Range
DerLigne = Cells(Rows.Count, 1).End(xlUp).Row
Sheets("échantillon daté").AutoFilterMode = False
ReDim Tabl(Ctr)
Ctr = -1
Set Plage = Range("B2:B" & DerLigne)
For Each C In Plage
If Not IsNumeric(Application.Match(Format(C.Value, "mm/dd/yyyy"), Tabl, 0)) Then
Ctr = Ctr + 1
ReDim Preserve Tabl(Ctr)
Tabl(Ctr) = Format(C.Value, "mm/dd/yyyy")
End If
Next C
For Each Item In Tabl
Sheets("échantillon daté").AutoFilterMode = False
Set Filtre = Range("B1:BH" & DerLigne)
Filtre.AutoFilter 1, ">=" & Item, xlAnd, "<=" & Item
Set Plage = Filtre.Offset(1, 9).Resize(Filtre.Rows.Count - 1, Filtre.Columns.Count - 9). _
SpecialCells(xlCellTypeVisible)
Var = Plage.Address
For Each C In Plage
If C.Value <> "" Then
Set C2 = Range(Cells(C.Row + 1, "K"), Cells(DerLigne, "BH")).Find(C.Value, , , xlWhole, xlByRows, xlPrevious)
If Not C2 Is Nothing Then
If C.Address = C2.Address Then Exit Sub
If CDate(Cells(C2.Row, "J").Value - Cells(C.Row, "H").Value) > CDate("13:30") Then
C.Interior.ColorIndex = 46
C2.Interior.ColorIndex = 46
End If
End If
End If
Next C
Next Item
Sheets("échantillon daté").AutoFilterMode = False
End Sub |
Partager