Macro Erreur Incomptaibilité de type

Bonjour,

J'ai une feuille Excel sur laquelle quand on tape une lettre par exemple O ça place un OUI dans la case. Jusque là tout va bien par contre après si je veux sélectionner plusieurs cellules et en effacer le contenu, je reçois une erreur d’incompatibilité qui me montre la deuxième ligne de ma macro. Si j'efface une seule case, je ne reçois aucun message d'erreur.

Une idée ? Merci.

Private Sub Worksheet_Change(ByVal Target As Range)

If UCase(Target.Value) = "O" Then
    Target.Value = "OUI"
End If
If UCase(Target.Value) = "N" Then
    Target.Value = "NON"
End If
If UCase(Target.Value) = "P" Then
    Target.Value = "Porte"
End If
If UCase(Target.Value) = "PF" Then
    Target.Value = "Porte Fenêtre"
End If
If UCase(Target.Value) = "C" Then
    Target.Value = "Coulissante"
End If
If UCase(Target.Value) = "S" Then
    Target.Value = "Simple Ouverture"
End If
If UCase(Target.Value) = "D" Then
    Target.Value = "Double Ouverture"
End If
If UCase(Target.Value) = "F" Then
    Target.Value = "Fixe"
End If
If UCase(Target.Value) = "A" Then
    Target.Value = "Assemblage"
End If
If UCase(Target.Value) = "G" Then
    Target.Value = "Porte de garage"
End If
If UCase(Target.Value) = "H" Then
    Target.Value = "Habillage d'angle"
End If
End Sub

Bonjour, Laurentp

A tester avec un code qui fonctionne selon le double-clic sur n'importe quelle feuille du classeur

Amicalement

Pierrot

Merci pour la solution.

Je valide la réponse.

Bonjour,

En vérifiant qu'une seule cellule est modifiée ?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count=1 Then
If UCase(Target.Value) = "O" Then
    Target.Value = "OUI"
End If
If UCase(Target.Value) = "N" Then
    Target.Value = "NON"
End If
If UCase(Target.Value) = "P" Then
    Target.Value = "Porte"
End If
If UCase(Target.Value) = "PF" Then
    Target.Value = "Porte Fenêtre"
End If
If UCase(Target.Value) = "C" Then
    Target.Value = "Coulissante"
End If
If UCase(Target.Value) = "S" Then
    Target.Value = "Simple Ouverture"
End If
If UCase(Target.Value) = "D" Then
    Target.Value = "Double Ouverture"
End If
If UCase(Target.Value) = "F" Then
    Target.Value = "Fixe"
End If
If UCase(Target.Value) = "A" Then
    Target.Value = "Assemblage"
End If
If UCase(Target.Value) = "G" Then
    Target.Value = "Porte de garage"
End If
If UCase(Target.Value) = "H" Then
    Target.Value = "Habillage d'angle"
End If
End If
End Sub
 
Rechercher des sujets similaires à "macro erreur incomptaibilite type"