Je voudrais colorer mes cellules suivant ce qu'elles contiennent
Ma plage de cellule s'appelle Plan_fixe et ma feuille Cartes.
Je pensais avoir bien fait mais excel me met "incompatibilité de type" dès
"if c="" then" et je ne comprends pas pourquoi...
Je vous mets mon code :
'Coloration du plan fixe (couleurs arbitraires)
'
Sub plan_fixe(Target)
Dim c As Range
For Each c In Worksheets("Cartes").Range("Plan_fixe")
If c = "" Then
c.Interior.ColorIndex = 36
ElseIf c = 0 Then
c.Interior.ColorIndex = 1
ElseIf c = 1 Then
c.Interior.ColorIndex = 12
ElseIf c = 24 Then
c.Interior.ColorIndex = 16
ElseIf c = 92 Then
c.Interior.ColorIndex = 43
ElseIf c = 418 Then
c.Interior.ColorIndex = 24
ElseIf c = 521 Then
c.Interior.ColorIndex = 26
ElseIf c = 832 Then
c.Interior.ColorIndex = 17
ElseIf c = 833 Then
c.Interior.ColorIndex = 32
ElseIf c = 834 Then
c.Interior.ColorIndex = 50
ElseIf c = 920 Then
c.Interior.ColorIndex = 23
ElseIf c = 1902 Then
c.Interior.ColorIndex = 40
ElseIf c = 8815 Then
c.Interior.ColorIndex = 42
ElseIf c = 8418 Then
c.Interior.ColorIndex = 45
ElseIf c = 8653 = 44 Then
c.Interior.ColorIndex = 15
ElseIf c = 8902 Then
c.Interior.ColorIndex = 35
ElseIf c = 9010 Then
c.Interior.ColorIndex = 6
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
JFrancois QC
Salut Élodie, Il y a confusion entre le nom de ta macro et de la plage à colorier.... renomme ta sub .
Bonjour,
Je voudrais colorer mes cellules suivant ce qu'elles contiennent
Ma plage de cellule s'appelle Plan_fixe et ma feuille Cartes. Je pensais avoir bien fait mais excel me met "incompatibilité de type" dès "if c="" then" et je ne comprends pas pourquoi...
Je vous mets mon code :
'Coloration du plan fixe (couleurs arbitraires) ' Sub plan_fixe(Target) Dim c As Range For Each c In Worksheets("Cartes").Range("Plan_fixe") If c = "" Then c.Interior.ColorIndex = 36 ElseIf c = 0 Then c.Interior.ColorIndex = 1 ElseIf c = 1 Then c.Interior.ColorIndex = 12 ElseIf c = 24 Then c.Interior.ColorIndex = 16 ElseIf c = 92 Then c.Interior.ColorIndex = 43 ElseIf c = 418 Then c.Interior.ColorIndex = 24 ElseIf c = 521 Then c.Interior.ColorIndex = 26 ElseIf c = 832 Then c.Interior.ColorIndex = 17 ElseIf c = 833 Then c.Interior.ColorIndex = 32 ElseIf c = 834 Then c.Interior.ColorIndex = 50 ElseIf c = 920 Then c.Interior.ColorIndex = 23 ElseIf c = 1902 Then c.Interior.ColorIndex = 40 ElseIf c = 8815 Then c.Interior.ColorIndex = 42 ElseIf c = 8418 Then c.Interior.ColorIndex = 45 ElseIf c = 8653 = 44 Then c.Interior.ColorIndex = 15 ElseIf c = 8902 Then c.Interior.ColorIndex = 35 ElseIf c = 9010 Then c.Interior.ColorIndex = 6
Else c.Interior.ColorIndex = 2
End If
Next End Sub
Merci d'avance!
Elodie
Salut Élodie,
Il y a confusion entre le nom de ta macro et de la plage à colorier....
renomme ta sub .
Bonjour,
Je voudrais colorer mes cellules suivant ce qu'elles contiennent
Ma plage de cellule s'appelle Plan_fixe et ma feuille Cartes.
Je pensais avoir bien fait mais excel me met "incompatibilité de type" dès
"if c="" then" et je ne comprends pas pourquoi...
Je vous mets mon code :
'Coloration du plan fixe (couleurs arbitraires)
'
Sub plan_fixe(Target)
Dim c As Range
For Each c In Worksheets("Cartes").Range("Plan_fixe")
If c = "" Then
c.Interior.ColorIndex = 36
ElseIf c = 0 Then
c.Interior.ColorIndex = 1
ElseIf c = 1 Then
c.Interior.ColorIndex = 12
ElseIf c = 24 Then
c.Interior.ColorIndex = 16
ElseIf c = 92 Then
c.Interior.ColorIndex = 43
ElseIf c = 418 Then
c.Interior.ColorIndex = 24
ElseIf c = 521 Then
c.Interior.ColorIndex = 26
ElseIf c = 832 Then
c.Interior.ColorIndex = 17
ElseIf c = 833 Then
c.Interior.ColorIndex = 32
ElseIf c = 834 Then
c.Interior.ColorIndex = 50
ElseIf c = 920 Then
c.Interior.ColorIndex = 23
ElseIf c = 1902 Then
c.Interior.ColorIndex = 40
ElseIf c = 8815 Then
c.Interior.ColorIndex = 42
ElseIf c = 8418 Then
c.Interior.ColorIndex = 45
ElseIf c = 8653 = 44 Then
c.Interior.ColorIndex = 15
ElseIf c = 8902 Then
c.Interior.ColorIndex = 35
ElseIf c = 9010 Then
c.Interior.ColorIndex = 6
Salut Élodie, Il y a confusion entre le nom de ta macro et de la plage à colorier.... renomme ta sub .
Bonjour,
Je voudrais colorer mes cellules suivant ce qu'elles contiennent
Ma plage de cellule s'appelle Plan_fixe et ma feuille Cartes. Je pensais avoir bien fait mais excel me met "incompatibilité de type" dès "if c="" then" et je ne comprends pas pourquoi...
Je vous mets mon code :
'Coloration du plan fixe (couleurs arbitraires) ' Sub plan_fixe(Target) Dim c As Range For Each c In Worksheets("Cartes").Range("Plan_fixe") If c = "" Then c.Interior.ColorIndex = 36 ElseIf c = 0 Then c.Interior.ColorIndex = 1 ElseIf c = 1 Then c.Interior.ColorIndex = 12 ElseIf c = 24 Then c.Interior.ColorIndex = 16 ElseIf c = 92 Then c.Interior.ColorIndex = 43 ElseIf c = 418 Then c.Interior.ColorIndex = 24 ElseIf c = 521 Then c.Interior.ColorIndex = 26 ElseIf c = 832 Then c.Interior.ColorIndex = 17 ElseIf c = 833 Then c.Interior.ColorIndex = 32 ElseIf c = 834 Then c.Interior.ColorIndex = 50 ElseIf c = 920 Then c.Interior.ColorIndex = 23 ElseIf c = 1902 Then c.Interior.ColorIndex = 40 ElseIf c = 8815 Then c.Interior.ColorIndex = 42 ElseIf c = 8418 Then c.Interior.ColorIndex = 45 ElseIf c = 8653 = 44 Then c.Interior.ColorIndex = 15 ElseIf c = 8902 Then c.Interior.ColorIndex = 35 ElseIf c = 9010 Then c.Interior.ColorIndex = 6