probleme formule condition

gao77610

XLDnaute Nouveau
probleme formule condition vba

Bonjour à tous

Voici mon soucis, la premiere condition fonctionne mais pas les 2 autres

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or Intersect(Target, Columns(1)) Is Nothing Then Exit Sub
If Left(Target, 5) = "36613" Then Sheets("StockBox").Range("b2").Value = Sheets("StockBox").Range("b2").Value + 1

If Target.Cells.Count > 1 Or Intersect(Target, Columns(2)) Is Nothing Then Exit Sub
If Left(Target, 5) = "12345" Then Sheets("StockBox").Range("c2").Value = Sheets("StockBox").Range("c2").Value + 1

If Target.Cells.Count > 1 Or Intersect(Target, Columns(3)) Is Nothing Then Exit Sub
If Left(Target, 5) = "67890" Then Sheets("StockBox").Range("d2").Value = Sheets("StockBox").Range("d2").Value + 1
End Sub

J'aimerais comprendre pourquoi

Merci par avance
 
Dernière édition:

Robert

XLDnaute Barbatruc
Repose en paix
Re : probleme formule condition

Bonjour Gao, bonjour le forum,

Dans la première ligne tu demandes au code de sortir de la procédure si tu "changes" ailleurs qu'en colonne A... Donc le code fait ce que tu lui demandes. Essaie comme ça (non testé) :
Code:
If Target.Cells.Count > 1 Or Intersect(Target, Columns("A:C")) Is Nothing Then Exit Sub
 
Dernière édition:

gao77610

XLDnaute Nouveau
Re : probleme formule condition

Re

Merci pour l'info, voila ce que j'ai fais etcela fonctionne:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or Intersect(Target, Columns("a:d")) Is Nothing Then Exit Sub
If Left(Target, 5) = "36613" Then Sheets("StockBox").Range("b2").Value = Sheets("StockBox").Range("b2").Value + 1

If Target.Cells.Count > 1 Or Intersect(Target, Columns("b:d")) Is Nothing Then Exit Sub
If Left(Target, 5) = "12345" Then Sheets("StockBox").Range("c2").Value = Sheets("StockBox").Range("c2").Value + 1

If Target.Cells.Count > 1 Or Intersect(Target, Columns("c:d")) Is Nothing Then Exit Sub
If Left(Target, 5) = "67890" Then Sheets("StockBox").Range("d2").Value = Sheets("StockBox").Range("d2").Value + 1
End Sub
 

Discussions similaires

Réponses
1
Affichages
280

Membres actuellement en ligne

Statistiques des forums

Discussions
312 749
Messages
2 091 623
Membres
105 009
dernier inscrit
aurelien76110