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 80 81 82 83
| Option Explicit
Dim i As Byte
Dim DerLig As Long
Private Sub CommandButton3_Click()
'ActiveSheet.Protect "*69*", UserInterfaceOnly:=True
Unload Me
Sheets("Gestion bobine").Select
Range("A1").Select
End Sub
Private Sub CommandButton4_Click()
If ListBox1.Value = "" Then MsgBox "Cocher une valeur !": Exit Sub
If ListBox2.Value = "" Then MsgBox "Cocher une valeur !": Exit Sub
If ListBox3.Value = "" Then MsgBox "Cocher une valeur !": Exit Sub
If ListBox4.Value = "" Then MsgBox "Cocher une valeur !": Exit Sub
If ListBox5.Value = "" Then MsgBox "Cocher une valeur !": Exit Sub
If ListBox7.Value = "" Then MsgBox "Cocher une valeur !": Exit Sub
If ListBox6.Value = "" Then MsgBox "Veuillez remplir les champs correctement!": Exit Sub
If TextBox1.Value = "" Then MsgBox "Veuillez remplir les champs correctement!": Exit Sub
If TextBox2.Value = "" Or Not IsNumeric(TextBox2.Value) Then MsgBox "Nombre de caisses non valide!": Exit Sub
TextBox1.Value = UCase(TextBox1.Value)
Range("E2") = TextBox1.Value
If Range("H2").Value = "NON" Then MsgBox "Formule déja validée": Exit Sub
Dim ShtD As Worksheet
Set ShtD = Sheets("BASE")
' Récupère la dernière ligne de la feuille de données
DerLig = ShtD.Range("C500").End(xlUp).Row
' colle les valeurs
ShtD.Range("C" & DerLig + 1).Value = Me.TextBox1.Value
ShtD.Range("D" & DerLig + 1).Value = Me.ListBox6.Value
ShtD.Range("E" & DerLig + 1).Value = Me.ListBox1.Value
ShtD.Range("F" & DerLig + 1).Value = Me.TextBox2.Value
ShtD.Range("H" & DerLig + 1).Value = Me.ListBox2.Value
ShtD.Range("N" & DerLig + 1).Value = Me.ListBox5.Value
ShtD.Range("P" & DerLig + 1).Value = Me.ListBox4.Value
ShtD.Range("U" & DerLig + 1).Value = Me.ListBox3.Value
ShtD.Range("V" & DerLig + 1).Value = Me.ListBox7.Value
'ActiveSheet.Protect "*69*", UserInterfaceOnly:=True
Unload Me
MsgBox "Formule enregistrée!"
Sheets("Gestion bobine").Select
Range("A1").Select
'ActiveWorkbook.Save
End Sub
Private Sub ListBox6_Click()
If ListBox6.Value = Range("Composants!B5").Value Then ListBox2.RowSource = "Composants!C7"
If ListBox6.Value = Range("Composants!B6").Value Then ListBox2.RowSource = "Composants!C12"
If ListBox6.Value = Range("Composants!B7").Value Then ListBox2.RowSource = "Composants!C17"
If ListBox6.Value = Range("Composants!B8").Value Then ListBox2.RowSource = "Composants!C22"
If ListBox6.Value = Range("Composants!B9").Value Then ListBox2.RowSource = "Composants!C26:C27"
If ListBox6.Value = Range("Composants!B11").Value Then ListBox2.RowSource = "Composants!C37"
'
If ListBox6.Value = Range("Composants!B5").Value Then ListBox4.RowSource = "Composants!C6"
If ListBox6.Value = Range("Composants!B6").Value Then ListBox4.RowSource = "Composants!C11"
If ListBox6.Value = Range("Composants!B7").Value Then ListBox4.RowSource = "Composants!C16"
If ListBox6.Value = Range("Composants!B8").Value Then ListBox4.RowSource = "Composants!C21"
If ListBox6.Value = Range("Composants!B9").Value Then ListBox4.RowSource = "Composants!C26:C27"
If ListBox6.Value = Range("Composants!B11").Value Then ListBox4.RowSource = "Composants!C36"
'
End Sub
Private Sub UserForm_Activate()
Worksheets("Composants").Activate
Range("E2").Select
Selection.ClearContents
TextBox1.Value = ""
ListBox1.RowSource = "COMPOSANTS!A5:A1000"
ListBox3.RowSource = "COMPOSANTS!A5:A1000"
ListBox5.RowSource = "COMPOSANTS!A5:A1000"
ListBox6.RowSource = "COMPOSANTS!B5:B20"
End Sub
Private Sub UserForm_Initialize()
End Sub |
Partager