Colorier une cellule

r4944 Messages postés 122 Date d'inscription   Statut Membre Dernière intervention   -  
r4944 Messages postés 122 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour ,

Comment je peux colorier les cellules qui on été remplies par des xx voici mon code :
Sub Decision()


Dim cell As Range

Dim i As Integer



For i = 2 To ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row

If CStr(ActiveSheet.Cells(i, 31).Value) = "Completed - Appointment made / Complété - Nomination faite" Or CStr(ActiveSheet.Cells(i, 31).Value) = "Completed - Inventory available / Complété - Inventaire disponible" Or _
CStr(ActiveSheet.Cells(i, 31).Value) = "Completed - Pool Created/ Complété - Bassin crée" Then


ActiveSheet.Cells(i, 42).Value = "XX"



' ElseIf ActiveSheet.Cells(i, 4).Text <> "" Then


' ActiveSheet.Cells(i, 42).Value = "Complete"



End If


Next i


End Sub


1 réponse

f894009 Messages postés 17277 Date d'inscription   Statut Membre Dernière intervention   1 713
 
Bonjour,

une facon de faire:

Sub Decision()
    Dim cell As Range
    Dim i As Integer,Fin as Long

    With ActiveSheet
        Fin = .Cells(.Rows.Count, 1).End(xlUp).Row
        For i = 2 To Fin
            If .Cells(i, 31).Value = "Completed - Appointment made / Complété - Nomination faite" Or _
                .Cells(i, 31).Value = "Completed - Inventory available / Complété - Inventaire disponible" Or _
                .Cells(i, 31).Value = "Completed - Pool Created/ Complété - Bassin crée" Then
                .Cells(i, 42).Value = "XX"
                .Cells(i, 42).Interior.Color = vbRed        'rouge
            ' ElseIf .Cells(i, 4).Text <> "" Then
                ' .Cells(i, 42).Value = "Complete"
            End If
        Next i
    End With
End Sub
1
r4944 Messages postés 122 Date d'inscription   Statut Membre Dernière intervention  
 
Merci pour votre réponse :)
0