Excel - Incompatibilité de type
Résolu
tbeghain
Messages postés
58
Date d'inscription
Statut
Membre
Dernière intervention
-
tbeghain Messages postés 58 Date d'inscription Statut Membre Dernière intervention -
tbeghain Messages postés 58 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Dans une feuille Excel, je voulais colorier des cellules avec des couleurs différentes selon la valeur du ciontenu de ces cellules. j'ai trouvé sur Internet un bout de code que j'ai adapté et qui remplit très bien cette fonction.
Seulement voilà, lorsque je veux copier, supprimer, ou insérer une ligne, j'ai un message :
'Erreur d'exécution 13 : Incompatibilité de type', et je ne comprends pas pourquoi. Voilà la bout de code en question que j'ai inséré dans ma feuille Excel :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value = "Pas d'info" Then
Target.Interior.ColorIndex = 35
End If
If Target.Value = "En attente" Then
Target.Interior.ColorIndex = 34
End If
If Target.Value = "En cours" Then
Target.Interior.ColorIndex = 36
End If
If Target.Value = "Ne fonctionne pas" Then
Target.Interior.ColorIndex = 3
End If
If Target.Value = "Annulé" Then
Target.Interior.ColorIndex = 40
End If
If Target.Value = "Terminé" Then
Target.Interior.ColorIndex = 4
End If
End Sub
Est-ce qu'il faut mettre autre chose ?
Merci
Dans une feuille Excel, je voulais colorier des cellules avec des couleurs différentes selon la valeur du ciontenu de ces cellules. j'ai trouvé sur Internet un bout de code que j'ai adapté et qui remplit très bien cette fonction.
Seulement voilà, lorsque je veux copier, supprimer, ou insérer une ligne, j'ai un message :
'Erreur d'exécution 13 : Incompatibilité de type', et je ne comprends pas pourquoi. Voilà la bout de code en question que j'ai inséré dans ma feuille Excel :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value = "Pas d'info" Then
Target.Interior.ColorIndex = 35
End If
If Target.Value = "En attente" Then
Target.Interior.ColorIndex = 34
End If
If Target.Value = "En cours" Then
Target.Interior.ColorIndex = 36
End If
If Target.Value = "Ne fonctionne pas" Then
Target.Interior.ColorIndex = 3
End If
If Target.Value = "Annulé" Then
Target.Interior.ColorIndex = 40
End If
If Target.Value = "Terminé" Then
Target.Interior.ColorIndex = 4
End If
End Sub
Est-ce qu'il faut mettre autre chose ?
Merci
A voir également:
- Excel - Incompatibilité de type
- Liste déroulante excel - Guide
- Word et excel gratuit - Guide
- Déplacer colonne excel - Guide
- Si ou excel - Guide
- Fiche de pointage excel - Télécharger - Tableur
2 réponses
Bonjour,
Ton code modifié :
eric
Ton code modifié :
Private Sub Worksheet_Change(ByVal Target As Range) If Not Target Is Nothing And Target.Cells.Count = 1 Then Select Case Target.Value Case "Pas d'info" Target.Interior.ColorIndex = 35 Case "En attente" Target.Interior.ColorIndex = 34 Case "En cours" Target.Interior.ColorIndex = 36 Case "Ne fonctionne pas" Target.Interior.ColorIndex = 3 Case "Annulé" Target.Interior.ColorIndex = 40 Case "Terminé" Target.Interior.ColorIndex = 4 End Select End If End Sub
eric