If (Target.Value) Erreur d'exécution 6 Dépassement de capacité [Résolu/Fermé]

Signaler
-
 Laurent -
Bonjour à Tous!

Je suis néophyte en VBA et l'erreur d'écution 6 s'afiche lorsque je lance le code suivant:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 4 _
And Target.Row >= 2 Then
If (Target.Value) = "1300100494" Or "1300100514" Or "1300100450" Or "1300100441" Or "1200018333" Or "1300098038" Or "1300096686" Or "2200728167" Or "1300090651" Or "1300088049" Or "1300066116" Or "1300093191" Or "1300084006" Or "1300078152" Or "1300074192" Or "1300074152" Or "1200003802" Or "1300070121" Or "1100147898" Or "2200387219" Or "1300060051" Or "1300060052" Or "1300059909" Or "1300060055" Or "1300060016" Or "1300060057" Or "1300060058" Or "1300060046" Or "1300060047" Or "1300060059" Or "1300060048" Or "1300059470" Or "1300062929" Or "1300059761" Or "1700050992" Or "1300060118" Or "1300055672" Or "1300071085" Or "1300074176" Or "1300074177" Or "1300074178" Or "1300074179" Or "1300074260" Or "1300074261" Then
Target.EntireRow.Interior.ColorIndex = 3
Else
Target.EntireRow.Interior.ColorIndex = 0
End If
End If
End Sub

Le but de mon code (récupérer sur internet) est tout bête, mettre en rouge automatiquement les lignes contenant certaines valeurs.

Pouvez-vous m'aider?

1 réponse

Messages postés
3334
Date d'inscription
samedi 20 juillet 2013
Statut
Membre
Dernière intervention
9 décembre 2016
496
Bonjour,

Essaie comme cela
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 4 And Target.Row >= 2 Then
Select Case Target.Value
Case "1300100494", "1300100514", "1300100450", "1300100441", "1200018333", "1300098038", _
"1300096686", "2200728167", "1300090651", "1300088049", "1300066116", "1300093191", _
"1300084006", "1300078152", "1300074192", "1300074152", "1200003802", "1300070121", _
"1100147898", "2200387219", "1300060051", "1300060052", "1300059909", "1300060055", _
"1300060016", "1300060057", "1300060058", "1300060046", "1300060047", "1300060059", _
"1300060048", "1300059470", "1300062929", "1300059761", "1700050992", "1300060118", _
"1300055672", "1300071085", "1300074176", "1300074177", "1300074178", "1300074179", _
"1300074260", "1300074261"
Target.EntireRow.Interior.ColorIndex = 3
Case Else
Target.EntireRow.Interior.ColorIndex = 0
End Select
End If
End Sub

A+