Exécuter la suite de l' equation après avoir utiliser exit s
t
Bonjour voila mon problème ,j'aimerais exécuter les codes derrière un bouton que j'ai créer dans un userforme . j'ai poser des conditions qui lorsqu'ils ne sont pas vérifier l'exécution doit s’arrêter ,mais le problème est que si les conditions sont respectées la suite du code ne s'execute plus.
voici le code en question . merci
Private Sub Enrgstr_Click()
If Qtité_cmde.Value = "" Then MsgBox ("veuillez entré unne quantité")
Exit Sub
If prix_achat.Value = "" Then MsgBox ("veuillez entré le prix d'achat")
Exit Sub
'enrégistrement des produits comandées
For i = 1 To Derline(1, 1)
If (Nom_prdt.Value = Sheets("PRODUIT").Cells(i + 1, 1)) Then
Sheets("PRODUIT").Cells(i + 1, 4) = Sheets("PRODUIT").Cells(i + 1, 4) + Qtité_cmde.Value
End If
Next i
If (flag = False) Then
Rows("2:2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("PRODUIT").Cells(2, 1) = Nom_prdt.Value
Sheets("PRODUIT").Cells(2, 2) = Type_prdt.Value
Sheets("PRODUIT").Cells(2, 3) = code_prdt.Value
Sheets("PRODUIT").Cells(2, 4) = Qtité_cmde.Value
Sheets("PRODUIT").Cells(2, 6) = prix_achat.Value
Sheets("PRODUIT").Cells(2, 8) = Dat_achat.Value
Sheets("PRODUIT").Cells(2, 9) = Dat_premp.Value
Sheets("PRODUIT").Cells(2, 10) = Nom_grosis.Value
Sheets("PRODUIT").Cells(2, 11) = Adres_gross.Value
End If
Nom_prdt.Value = ""
Type_prdt.Value = ""
code_prdt.Value = ""
Qtité_cmde.Value = ""
prix_achat.Value = ""
Dat_achat.Value = ""
Dat_premp.Value = ""
Nom_grosis.Value = ""
Adres_gross.Value = ""
Rows("2:2").Select
With Selection.Font
.Name = "Calibri"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
Selection.Font.Bold = False
Selection.Font.Italic = False
End SubBonjour,
A tester.
Cdlt.
Option Explicit
Private Sub Enrgstr_Click()
Dim ws As Worksheet
Dim I As Long
If Qtité_cmde.Value = "" Then
MsgBox ("veuillez entré unne quantité")
Exit Sub
End If
If prix_achat.Value = "" Then
MsgBox ("veuillez entré le prix d'achat")
Exit Sub
End If
Set ws = Worksheets("PRODUIT")
For I = 1 To Derline(1, 1)
If (Nom_prdt.Value = ws.Cells(I + 1, 1)) Then
ws.Cells(I + 1, 4) = ws.Cells(I + 1, 4) + Qtité_cmde.Value
End If
If flag = False Then
With ws
With .Rows("2:2")
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
.Font.Name = "Calibri"
.Font.ThemeFont = xlThemeFontMinor
End With
.Cells(2, 1) = Nom_prdt.Value
.Cells(2, 2) = Type_prdt.Value
.Cells(2, 3) = code_prdt.Value
.Cells(2, 4) = Qtité_cmde.Value
.Cells(2, 6) = prix_achat.Value
.Cells(2, 8) = Dat_achat.Value
.Cells(2, 9) = Dat_premp.Value
.Cells(2, 10) = Nom_grosis.Value
.Cells(2, 11) = Adres_gross.Value
End With
End If
Next I
Nom_prdt.Value = ""
Type_prdt.Value = ""
code_prdt.Value = ""
Qtité_cmde.Value = ""
prix_achat.Value = ""
Dat_achat.Value = ""
Dat_premp.Value = ""
Nom_grosis.Value = ""
Adres_gross.Value = ""
End Subt
Merci ca ma beaucoup aider.