Colorier une cellule

Fermé
r4944 Messages postés 122 Date d'inscription vendredi 2 octobre 2015 Statut Membre Dernière intervention 3 mars 2017 - 9 oct. 2015 à 15:43
r4944 Messages postés 122 Date d'inscription vendredi 2 octobre 2015 Statut Membre Dernière intervention 3 mars 2017 - 9 oct. 2015 à 17:40
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 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 1 701
9 oct. 2015 à 16:11
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 vendredi 2 octobre 2015 Statut Membre Dernière intervention 3 mars 2017
9 oct. 2015 à 17:40
Merci pour votre réponse :)
0