1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| Private Sub Prixajout_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("1234567890,-", Chr(KeyAscii)) = 0 Then KeyAscii = 0: Beep
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Prixajout.Value = "" Or Nomajout = "" Then
BoutonAjout.Visible = False
Else
BoutonAjout.Visible = True
End If
End Sub
Private Sub BoutonAjout_Click()
Prixajout = Format(Prixajout, "currency")
nblignes = Application.CountA(Sheets("Produits").Range("B4:A1000"))
For i = 1 To nblignes + 1
If Cells(i, 1) = Nomajout.Value Then
MsgBox "Veuillez changer de nom car cette boisson existe déja"
Nomajout.Value = ""
Prixajout.Value = ""
Exit Sub
End If
Next
Range("modele2").Copy
Range("B4").Offset(nblignes, 0).Value = Nomajout.Value
Range("B4").Offset(nblignes, 0).PasteSpecial xlPasteFormats
Range("modele").Copy
Range("B4").Offset(nblignes, 1).Value = Prixajout.Value
Range("B4").Offset(nblignes, 1).PasteSpecial xlPasteFormats
Nomajout.Value = ""
Prixajout.Value = ""
End Sub |
Partager