Xl format conditionnel erreur execution 13

Résolu
gekkoko Messages postés 2 Date d'inscription mardi 10 octobre 2006 Statut Membre Dernière intervention 11 octobre 2006 - 10 oct. 2006 à 22:13
gekkoko Messages postés 2 Date d'inscription mardi 10 octobre 2006 Statut Membre Dernière intervention 11 octobre 2006 - 11 oct. 2006 à 01:09
Bonjour,

J'ai fait 1 fichier excel avec mise en forme conditionnelle des cases.
Le nombre de conditions étant supérieur à 3 j'ai utilisé un tutoriel avec le code suivant :

Private Sub Worksheet_Change(ByVal Target As Range)If Target.Value "A" Then Target.Interior.ColorIndex 42If Target.Value "B" Then Target.Interior.ColorIndex 43If Target.Value "C" Then Target.Interior.ColorIndex 44If Target.Value "D" Then Target.Interior.ColorIndex 36If Target.Value "E" Then Target.Interior.ColorIndex 37If Target.Value "F" Then Target.Interior.ColorIndex 38If Target.Value "G" Then Target.Interior.ColorIndex 39If Target.Value "H" Then Target.Interior.ColorIndex 40If Target.Value "" Then Target.Interior.ColorIndex 2


End Sub

Mon problème c'est que lorsque sur ma feuille excel je supprime le contenu de plusieurs cellules en même temps (c'est à dire sélectionner les cellule et suppr.) l'erreur suivante apparaît : "erreur d'execution '13' Incompatibilité de type" je clique sur le bouton fin de la fenetre qui propose le deboggeur et tout fonctionne mais comment éviter d'avoir cet avertissement ???

Merci d'avance.

PS : je suis hyper néophite !!!

2 réponses

cs_MPi Messages postés 3877 Date d'inscription mardi 19 mars 2002 Statut Membre Dernière intervention 17 août 2018 23
11 oct. 2006 à 00:03
Salut,

Je pense que ceci devrait fonctionner


    Dim Cellule As Range

   

    For Each Cellule In Target.Cells

        If Cellule "A" Then Cellule.Interior.ColorIndex 42

        If Cellule "B" Then Cellule.Interior.ColorIndex 43

        If Cellule "C" Then Cellule.Interior.ColorIndex 44

        If Cellule "D" Then Cellule.Interior.ColorIndex 36

        If Cellule "E" Then Cellule.Interior.ColorIndex 37

        If Cellule "F" Then Cellule.Interior.ColorIndex 38

        If Cellule "G" Then Cellule.Interior.ColorIndex 39

        If Cellule "H" Then Cellule.Interior.ColorIndex 40

        If Cellule "" Then Cellule.Interior.ColorIndex 2

    Next

MPi
3
gekkoko Messages postés 2 Date d'inscription mardi 10 octobre 2006 Statut Membre Dernière intervention 11 octobre 2006
11 oct. 2006 à 01:09
1 GRAND MERCI !!!!!!
0
Rejoignez-nous