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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| Option Explicit
Function IsRefExist(rng As Range, ref As String) As Boolean
IsRefExist = Application.CountIf(rng, ref) = 0
End Function
Private Sub CommandButton8_Click()
Sheets("Machines").Activate
Dim derligne As Integer
If MsgBox("Voulez-vous ajouter cette machine?", vbYesNo, "confirmation") = vbYes Then
derligne = Sheets("Machines").Range("A10000").End(xlUp).Row + 2
Cells(derligne, 1) = TextBox1.Value
Cells(derligne, 2) = TextBox2.Value
Cells(derligne, 3) = TextBox3.Value
Cells(derligne, 4) = TextBox4.Value
Cells(derligne, 5) = TextBox5.Value
Cells(derligne, 6) = TextBox6.Value
Cells(derligne, 7) = TextBox7.Value
Cells(derligne, 9) = TextBox8.Value
Cells(derligne, 10) = TextBox9.Value
Cells(derligne, 11) = TextBox10.Value
Cells(derligne, 12) = TextBox11.Value
Cells(derligne, 13) = TextBox12.Value
Cells(derligne, 14) = TextBox13.Value
Cells(derligne, 15) = TextBox15.Value
Cells(derligne, 16) = TextBox16.Value
End If
Unload Me
AjouterUneOuDesmachines.Show
End Sub
Private Sub CommandButton7_Click() 'Vider les champs d'ajout de machine'
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
TextBox10.Value = ""
TextBox11.Value = ""
TextBox12.Value = ""
TextBox13.Value = ""
TextBox14.Value = ""
TextBox15.Value = ""
TextBox16.Value = ""
End Sub
Private Sub CommandButton11_Click()
Unload AjouterUneOuDesmachines
MenuPrincipale.Show
End Sub
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim rg As Range
If TextBox1.Text = "" Then Exit Sub
Set rg = Sheets("Machines").Range("A:A").Find(TextBox1.Text)
If Not rg Is Nothing Then
MsgBox "Ancienne Réf Interne existante déja"
TextBox1 = ""
End If
End Sub
Private Sub TextBox2_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim rg As Range
If TextBox2.Text = "" Then Exit Sub
Set rg = Sheets("Machines").Range("B:B").Find(TextBox2.Text)
If Not rg Is Nothing Then
MsgBox "Nouvelle Réf Interne Existe Déjà"
TextBox2 = ""
End If
End Sub
Private Sub TextBox3_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim rg As Range
If TextBox3.Text = "" Then Exit Sub
Set rg = Sheets("Machines").Range("C:C").Find(TextBox3.Text)
If Not rg Is Nothing Then
MsgBox "Numéro de série fabriquant Existe Déjà"
TextBox3 = ""
End If
End Sub |