Re : Comment effacer la dernière action créer ?
Bonjour Mutsik,
je te joins le code de l'UserForm qui explique comment tout ce range.
le probléme et que je veux vider la quantité qui s'est rangé dans la feuille "Bibli" en même temps que j'efface le dernière ligne créer.
Private Sub UserForm_Initialize()
Sheets("Devis").Activate
Dim VarDerLigne As Integer
Dim VarPlageList As String
VarDerLigne = Sheets("Bibli").Range("A65536").End(xlUp).Row + 2
VarPlageList = Sheets("Bibli").Range("B2:B" & VarDerLigne).Address
ListBox1.RowSource = "Bibli!" & VarPlageList
End Sub
Private Sub ListBox1_Click()
VarSelectedArticle = UserForm1.ListBox1.ListIndex + 2
LabelPrixUnit.Visible = True
LabelUnite.Visible = True
TextBoxQuantite.Visible = True
LabelPrixTotal.Visible = True
LabelPrixUnit.Visible = True
TextBoxQuantite.Visible = True
LabelPrixTotal.Visible = True
LabelCode = Sheets("Bibli").Range("A" & VarSelectedArticle).Value
LabelPrixUnit = Format(Sheets("Bibli").Range("E" & VarSelectedArticle).Value, "#,##0.00")
LabelUnite = Sheets("Bibli").Range("D" & VarSelectedArticle).Value
LabelPrixTotal = ""
TextBoxQuantite = ""
End Sub
Private Sub TextBoxQuantite_Change()
Dim Chiffre As Integer
If TextBoxQuantite = "" Then Exit Sub
On Error GoTo Sortie
Chiffre = TextBoxQuantite
LabelPrixTotal = Format(LabelPrixUnit * TextBoxQuantite, "# ##0.00")
CommandButton1.Visible = True
Exit Sub
Sortie:
MsgBox "Saisir Uniquement un Entier Numérique"
End Sub
Private Sub CommandButton1_Click()
Dim VarDerL As Integer
Dim Quantite As Integer
VarDerL = Sheets("Devis").Range("B1000").End(xlUp).Row + 2
If TextBoxQuantite = "" Then
MsgBox "Vous Devez Saisir Une Quantité"
TextBoxQuantite.Visible = True
TextBoxQuantite.SetFocus
Exit Sub
End If
If TextBoxQuantite <= 0 Then
MsgBox "Vous Devez Saisir Une Valeur Positive "
TextBoxQuantite.Visible = True
TextBoxQuantite = ""
TextBoxQuantite.SetFocus
Exit Sub
End If
If Quantite Then
MsgBox "La quantité demandée " & TextBoxQuantite
TextBoxQuantite.Visible = True
TextBoxQuantite.SetFocus
Exit Sub
End If
If VarDerL = 1000 Then
MsgBox "Vous êtes arrivé à la dernière ligne de ce Devis", vbCritical, "Fin de Devis"
Exit Sub
End If
With Sheets("Devis")
.Range("A" & VarDerL) = LabelCode
.Range("B" & VarDerL) = ListBox1
.Range("C" & VarDerL) = TextBoxQuantite
.Range("D" & VarDerL) = LabelUnite
.Range("E" & VarDerL).Select
ActiveCell.FormulaR1C1 = "=IF(RC[2]>0,RC[2]*R8C10)"
.Range("F" & VarDerL).Select
ActiveCell.FormulaR1C1 = "=RC[-3]*RC[-1]"
.Range("G" & VarDerL) = Format(LabelPrixUnit, "# ##0.00")
.Range("H" & VarDerL) = Format(LabelPrixTotal, "#,##0.00")
.Range("I" & VarDerL).Select
ActiveCell.FormulaR1C1 = "=1-(RC[-2]/RC[-4])"
End With
Sheets("Bibli").Range("C" & VarSelectedArticle).Value = TextBoxQuantite
Exit Sub
Sortie:
MsgBox "La valeur de la Quantité ne peut être qu'un nombre entier !"
End Sub
Private Sub CommandButton3_Click()
Unload UserForm1
Sheets("Devis").Activate
ActiveWorkbook.Save
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
MsgBox "Vous ne pouvez pas utiliser ce bouton de fermeture."
Cancel = True
End If
End Sub
Merci d'avance