Re : comment intervenir au milieu d'une macro ?
Re le forum,
bonsoir JM et merci de t'intéresser à mon petit pb.
les lignes en rouge, sont les points importants de mon pb.
Bouton de validation de l'Userform2 don le nom est "Deplac"
Private Sub Valid_Click()
Dim L As Long
L = Fact.Range("B46").End(xlUp).Row + 1
If L >= 45 Then L = Fact.Range("B113").End(xlUp).Row + 1
With Fact
If TextBox2.Value <> "" Then
.Range("F" & L).Value = TextBox2.Value
.Range("A" & L).Value = "Déplacement"
.Range("B" & L).Value = "Forfait Déplacement"
.Range("D" & L) = "Ft"
Unload Deplac
Else:
.Range("F" & L).Value = TextBox1.Value
.Range("A" & L).Value = "Déplacement"
.Range("B" & L).Value = "Forfait Déplacement"
.Range("D" & L) = "Ft"
Unload Deplac
End If
End With
End Sub
De la fin de cette procédure, j'aimerais arriver directement à ce qui est également noter en rouge
dans la procédure suivante de l'Usf1
Private Sub CommandButton1_Click()
Dim i As Integer
Dim L, A As Long
Dim Ctrl As Control
Dim U As Range
Dim nFact, VarFacturier As String
Dim Réponse As String
Dim Quest, Request, AutreQuest, Remise, Hauteurtotaleligne, Hauteur, PtFourn
Fact.Activate
i = Fact.Range("B47").End(xlUp).Row
If i >= 45 Then GoTo 3
L = Fact.Range("B47").End(xlUp).Row + 1
If L > 20 Then
Hauteurtotaleligne = Fact.Range(Rows(18), Rows(46)).Height
If Hauteurtotaleligne > 415 Or Hauteurtotaleligne < 410 Then
For A = 46 To Fact.Range("B47").End(xlUp).Row + 1 Step -1
If Fact.Range(Rows(18), Rows(46)).Height < 410 Then
Hauteur = 410 - Hauteurtotaleligne
If Fact.Range("B" & A) = "" Then Rows(A).RowHeight = Rows(A).RowHeight + Hauteur
If Fact.Range(Rows(18), Rows(46)).Height > 410 Then Exit For
End If
If Fact.Range(Rows(18), Rows(46)).Height > 415 Then
If Fact.Range("B" & A) = "" Then Rows(A).RowHeight = 2
If Fact.Range(Rows(18), Rows(46)).Height < 415 Then Exit For
End If
Next
End If
End If
3 If i >= 45 Then
L = Fact.Range("B113").End(xlUp).Row + 1
End If
If UsF1.insert = True Then
Fact.Range("B46").End(xlUp).Offset(1, 0).Value = "*"
GoTo 2
End If
If UsF1.Dev = True Then
Range("ChoixGenre") = 2
Range("NumDevis").Value = Year(Date) & " " & "03" & " " & Range("ProchainNDevis")
Else: Range("ChoixGenre") = 1
End If
Range("LeClient").Value = CbxClient.Value
If Range("LeClient").Value = "" Then
MsgBox "Aucun Client n'est sélectionné."
Exit Sub
End If
If UsF1.ComboBox1.ListIndex = -1 Then
MsgBox "Pas de Selection Catégorie", vbCritical, "Invalide"
Exit Sub
End If
'If UsF1.ComboBox1 = "Déplacement" Then GoTo 4
If UsF1.ComboBox2 = "" Then
MsgBox "Pas de Selection Article", vbCritical, "Invalide"
Exit Sub
End If
If UsF1.PxUnit = "" Or UsF1.PxUnit = 0 Then
MsgBox "Pas de Prix", vbCritical, "Invalide"
Exit Sub
End If
If UsF1.Qte = "" Or UsF1.Qte = 0 Then
MsgBox "Pas de Quantité", vbCritical, "Invalide"
Exit Sub
End If
Range("Paiements").Value = "En Attente"
With Fact
.Range("A" & L) = UsF1.ComboBox1
.Range("B" & L) = UsF1.ComboBox2
.Range("E" & L) = CDbl(UsF1.PxUnit)
.Range("C" & L) = CDbl(UsF1.Qte)
.Range("F" & L) = Round(CDbl(UsF1.PxTotal), 2)
If UsF1.PxAcht.Value <> "" Then
.Range("H" & L) = Round(CDec(UsF1.PxAcht), 2)
End If
End With
Range("Objet_du_devis").Value = Fact.Range("B15").Value
2 With UsF1
.ComboBox1.ListIndex = -1
.ComboBox2.ListIndex = -1
.Qte.Value = 1
.PxTotal.Value = ""
.TextBox5.Value = ""
.PxAcht.Value = ""
End With
If UsF1.insert = False Then
Quest = MsgBox("Devez vous ajouter un article ?", vbYesNo, "Nouvel article ?")
insert.Value = False
End If
If Quest = vbNo Then
4 PtFourn = MsgBox("Petites Fournitures ?", vbYesNo)
If PtFourn = 6 Then '6 = vbyes
PetitesFournitures.Show
Else: Deplac.Show
End If
J'aimerais arriver ici après avoir cliqué sur le bouton valid de l'Userform2
If L <= 47 Then
Fact.Range("C47") = "Total HT"
Else
Fact.Range("C114") = "Total HT"
End If
If Factu = True Then
AutreQuest = MsgBox("Le client a-t-il versé un acompte", vbYesNo, "Acompte")
If AutreQuest = vbYes Then
Réponse = InputBox("Montant de l'acompte")
If Réponse = "" Then GoTo Suite
If Fact.Range("c47") <> "" Then
Fact.Range("C50") = "Acompte versé"
Fact.Range("F50") = "-" & Réponse
Else
Fact.Range("C117") = "Acompte versé"
Fact.Range("F117") = "-" & Réponse
End If
End If
End If
Suite:
If Fact.Range("C47") <> "" Then
Range("C51:F51").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Else
Range("C51:F51").Select
With Selection.Interior
.ColorIndex = xlNone
' .Pattern = xlSolid
End With
End If
EnregistrerFacture
Unload Me
End If
End Sub
je comprend bien que ce n'est pas le pied pour donner un coup de main !!!
mais je cherche à minimiser mon classeur afin de mieux vous expliquer.