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 48
   | Sub RechDate()
Dim Lig As Long, Col As Long
Dim Var1 As Long
Dim MaPlage As Range
Lig = Cells(Columns(1).Cells.Count, 1).End(xlUp).Row 'C'est la même chose que toi mais compatible XL2007
Col = Cells(2, Rows(2).Cells.Count).End(xlToLeft).Column 'Même principe que pour les lignes mais en colonne
Range(Cells(2, 4), Cells(Lig, Col)).Interior.ColorIndex = xlNone 'enlève les couleurs de fond
Range(Cells(2, 4), Cells(Lig, Col)).FormatConditions.Delete 'enlève la mise en forme conditionnelle
 
'Sélection et suppression des MEFC pour la date choisie
Var1 = Application.Match(ActiveSheet.Range("B1").Value2, ActiveSheet.Range("B2:IV2"), 0)
    If Not IsError(Var1) Then
        'Application des format conditionnel sur toute la plage pour remettre celles éventuellement supprimées
        Set MaPlage = Sheets("Présences").Range(Sheets("Présences").Cells(2, 4), Sheets("Présences").Cells(Lig, Col))
        MaPlage.FormatConditions.Delete
        MaPlage.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:="0"
        With MaPlage.FormatConditions(1).Font
            .Bold = True
            .Italic = False
            .ColorIndex = xlAutomatic
        End With
        MaPlage.FormatConditions(1).Interior.ColorIndex = 36
        MaPlage.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
        Formula1:="=""p"""
        With MaPlage.FormatConditions(2).Font
            .Bold = True
            .Italic = False
            .ColorIndex = xlAutomatic
        End With
        MaPlage.FormatConditions(2).Interior.ColorIndex = 35
        MaPlage.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
            Formula1:="=""p"""
        With MaPlage.FormatConditions(3).Font
            .Bold = True
            .Italic = False
            .ColorIndex = xlAutomatic
        End With
        MaPlage.FormatConditions(3).Interior.ColorIndex = 40
        'Fin de l'application des MEFC sur la plage concernée
        Cells(4, Var1).Select
        Columns(Var1).FormatConditions.Delete 'enlève la mise en forme conditionnelle
        Range(Cells(3, Var1), Cells(Lig, Var1)).Interior.ColorIndex = 4
    Else
        MsgBox "Date inexistante!"
End If
 
End Sub | 
Partager