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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
' permet d'afficher ou non l'ajout d'un utilisateur et la modification des droits en fonction de son login
Private Sub CommandButton2_Click()
Dim lesheet As Object
If CheckBox1.Value = CheckBox2.Value Then MsgBox "veuillez choisir une feuille": Exit Sub
If TextBox2 <> "" And TextBox3 <> "" And TextBox4 <> "" And TextBox7 <> "" And TextBox8 <> "" Then
If CheckBox1.Value = True Then
Set lesheet = Sheets("planification vrac")
Else
Set lesheet = Sheets("planification conditionnement")
End If
lesheet.Rows("4").Insert ' insert les donnees des box
lesheet.Range("A4") = Format(Date, "yyyy")
lesheet.Range("B4") = Format(Date, "mmmm")
lesheet.Range("C4") = Format(TextBox2.Value, "dd/mm/yyyy")
lesheet.Range("D4") = TextBox3
lesheet.Range("E4") = ComboBox1.Value
lesheet.Range("F4") = Val(Label8)
lesheet.Range("G4") = Val(TextBox7)
lesheet.Range("H4") = TextBox4
lesheet.Range("I4") = Format(TextBox8.Value, "dd/mm/yyyy")
lesheet.Range("J4") = (CVDate(TextBox2.Value) - CVDate(TextBox8.Value)) / 30
ComboBox1.Value = "" 'efface le contenue des box
TextBox3 = ""
Label8 = ""
TextBox7 = ""
TextBox8 = ""
TextBox4 = ""
TextBox2 = ""
CheckBox1.Value = False
CheckBox2.Value = False
couleur lesheet
produit ' charge la combobox
MsgBox "enregistrement effectué" & vbCrLf & "dans la feuille " & lesheet.Name
Else
MsgBox ("Il manque des données")
End If
End Sub
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case Len(TextBox2)
Case 0: If Chr(KeyAscii) > 3 Then KeyAscii = 0: Exit Sub
Case 2: If Chr(KeyAscii) > 1 Then KeyAscii = 0: Exit Sub
TextBox2 = IIf(TextBox2 > 31, 31, TextBox2)
TextBox2 = TextBox2 & "/"
Case 5: If Chr(KeyAscii) > 2 Then KeyAscii = 0: Exit Sub
TextBox2 = TextBox2 & "/"
Case 7: If Chr(KeyAscii) > 2 Then KeyAscii = 0: Exit Sub
Case 10: TextBox2 = Left(TextBox2, 10)
End Select
End Sub
Private Sub TextBox2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
TextBox2 = IIf(KeyCode = 8, "", TextBox2)
End Sub
Private Sub TextBox8_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case Len(TextBox8)
Case 0: If Chr(KeyAscii) > 3 Then KeyAscii = 0: Exit Sub
Case 2: If Chr(KeyAscii) > 1 Then KeyAscii = 0: Exit Sub
TextBox8 = IIf(TextBox8 > 31, 31, TextBox8)
TextBox8 = TextBox8 & "/"
Case 5: If Chr(KeyAscii) > 2 Then KeyAscii = 0: Exit Sub
TextBox8 = TextBox8 & "/"
Case 7: If Chr(KeyAscii) > 2 Then KeyAscii = 0: Exit Sub
Case 10: TextBox8 = Left(TextBox8, 10)
End Select
End Sub
Private Sub TextBox8_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
TextBox8 = IIf(KeyCode = 8, "", TextBox8)
End Sub
Private Sub UserForm_Initialize()
produit ' à l'ouverture de la fenetre ca charge la combobox1
End Sub
Sub produit()
ComboBox1.List() = Sheets("info produit").Range("B2", Sheets("info produit").Cells(Rows.Count, 2).End(xlUp)).Value
End Sub
Private Sub combobox1_Change() ' permet d'ajouter la categorie dans le label8
Label8 = Worksheets("info produit").Cells(ComboBox1.ListIndex + 2, 3)
End Sub
Private Sub CheckBox1_Click()
' si elle a coché la case vrac, la case conditionnement ne peut pas etre coché
If CheckBox1.Value = True Then CheckBox2.Value = False
End Sub
Private Sub CheckBox2_Click()
' si elle a coché la case conditionnement, la case vrac ne peut pas etre coché
If CheckBox2.Value = True Then CheckBox1.Value = False
End Sub
Sub couleur(feuille)
With feuille
'permet de mettre des couleurs dans la table.
Select Case .Cells(4, 6).Value
Case 1
.Range(.Cells(4, 6), .Cells(4, 6).Offset(0, -1)).Interior.Color = RGB(32, 255, 192)
Case 2
.Range(.Cells(4, 6), .Cells(4, 6).Offset(0, -1)).Interior.Color = RGB(128, 224, 255)
Case 3
.Range(.Cells(4, 6), .Cells(4, 6).Offset(0, -1)).Interior.Color = RGB(255, 255, 160)
Case 5
.Range(.Cells(4, 6), .Cells(4, 6).Offset(0, -1)).Interior.Color = RGB(255, 192, 128)
Case 6
.Range(.Cells(4, 6), .Cells(4, 6).Offset(0, -1)).Interior.Color = RGB(255, 128, 160)
End Select
End With
End Sub |