MSbox redonant
Bonjour
monde vba ci-dessous me reliance mes msgbox alors je veux que ca soit lancé une seul fois:
la valeur en A1,B1 et C1 doit etre superieur à 1 si on dit oui pour un lot 2 et/ou un lot 3
la valeur en A2,B2 et C2 doit etre supérieur à 0 si on dit oui pour un lot 2 et/ou un lot 3.
voici le code (voir aussi fichier attaché):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
'==========================
'=====================Lot 1
'==========================
If Worksheets("Feuil1").Cells(1, 1).Value = 1 Then
MsgBox ("Selectionner le Lot 1. Select the Lot 1")
Range("a1").Select
Else
If Worksheets("Feuil1").Cells(2, 1).Value = 0 Then
MsgBox ("Enter le T1 du Lot1. Enter the T1 of the Lot1")
Range("a2").Select
Else
'==========================
'=====================Lot 2
'==========================
If MsgBox("Un deuxieme Lot? A second Lot", vbYesNo + vbInformation, _
"Attention") = vbNo Then
Exit Sub
Else
If Worksheets("Feuil1").Cells(1, 2).Value = 1 Then
MsgBox ("Selectionner le Lot2. Select the Lot2")
Range("b1").Select
Else
If Worksheets("Feuil1").Cells(2, 2).Value = 0 Then
MsgBox ("Enter le T2 du Lot2. Enter the T2 of the Lot2")
Range("b2").Select
Else
'==========================
'=====================Lot 3
'==========================
If MsgBox("Un Troisieme Lot? A Third Lot", vbYesNo + vbInformation, _
"Attention") = vbNo Then
Exit Sub
Else
If Worksheets("Feuil1").Cells(1, 3).Value = 1 Then
MsgBox ("Selectionner le Lot3. Select the Lot3")
Range("c1").Select
Else
If Worksheets("Feuil1").Cells(2, 3).Value = 0 Then
MsgBox ("Enter le T3 du Lot3. Enter the T3 of the Lot3")
Range("c2").Select
Else
End If
Exit Sub
End If
End If
End If
End If
End If
End If
End If
Application.EnableEvents = True
End Sub
Bonsoir,
votre message est illisible sans l'utilisation des balise d'édition de message, et en plus votre code dans le fichier n'est pas "indenté"
ce qui fait qu'avec tous ces IF cela devient également illisible...
Bonne chance pour les futures réponses....
@ bientôt
LouReeD
Bonjour,
A tester !...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Me.Range("A1:C1")) Is Nothing Then
Application.EnableEvents = False
'Lot 1
If Worksheets("Feuil1").Cells(1, 1).Value = 1 Then
MsgBox ("Selectionner le Lot 1. Select the Lot 1")
Range("a1").Select
Else
If Worksheets("Feuil1").Cells(2, 1).Value = 0 Then
MsgBox ("Enter le T1 du Lot1. Enter the T1 of the Lot1")
Range("a2").Select
Else
'Lot 2
If MsgBox("Un deuxieme Lot? A second Lot", vbYesNo + vbInformation, "Attention") = vbNo Then
Exit Sub
Else
If Worksheets("Feuil1").Cells(1, 2).Value = 1 Then
MsgBox ("Selectionner le Lot2. Select the Lot2")
Range("b1").Select
Else
If Worksheets("Feuil1").Cells(2, 2).Value = 0 Then
MsgBox ("Enter le T2 du Lot2. Enter the T2 of the Lot2")
Range("b2").Select
Else
'Lot 3
If MsgBox("Un Troisieme Lot? A Third Lot", vbYesNo + vbInformation, "Attention") = vbNo Then
Exit Sub
Else
If Worksheets("Feuil1").Cells(1, 3).Value = 1 Then
MsgBox ("Selectionner le Lot3. Select the Lot3")
Range("c1").Select
Else
If Worksheets("Feuil1").Cells(2, 3).Value = 0 Then
MsgBox ("Enter le T3 du Lot3. Enter the T3 of the Lot3")
Range("c2").Select
End If
Exit Sub
End If
End If
End If
End If
End If
End If
End If
Application.EnableEvents = True
End If
End Submerci Jean-Eric pour ton essai, cependant ca ne marche pas, car il faut que si je clique ailleurs dans la feuille il faut que mon programme me ramene à la cellule pour repondre à chaque consdition pour la compléter
Bonsoir,
votre message est illisible sans l'utilisation des balise d'édition de message, et en plus votre code dans le fichier n'est pas "indenté"
ce qui fait qu'avec tous ces IF cela devient également illisible...
il me semble que ta question est très facile , mais elle serai plus facile si tu l’expose bien ,car la question est la moitié de réponse