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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
| Dim f
Private Sub UserForm_Initialize()
'positionnement du formulaire au centre de la feuille excel
Me.Left = Application.Left + Application.Width / 2 - Me.Width / 2
Me.Top = Application.Top + Application.Height / 2 - Me.Height / 2
Me.TextBox_nbr_pains = Sheets("LANCEMENT FORMULAIRE").Range("E69")
'Zone INFOJOUR
'Marque la date du jour
Me.LABEL_DATE = Sheets("parametre").Range("B7")
End Sub
'**************** champs temps limité au chiffre
Private Sub TextBox_article_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub TextBox_numero_lot_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub TextBox_numero_containers_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub TextBox_nbr_pains_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub TextBox_Petits_Pains_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub TextBox_Corcieux_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub TextBox_heure_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789hH", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub TextBox_poids_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789,.", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub
'***************** RAZ TABLEAU - ANNULE
Private Sub buttonANNULE_Click()
' Annulation du formulaire actif, RAZ des infos
Unload Me
ThisWorkbook.Worksheets("PARAMETRE").Range("B11") = Time
Containers.Show
End Sub
'---------- /!\ Bug au niveau de la validation avec donnée vide - a corriger
'**************** validation formulaire
Private Sub B_VALIDERG_Click()
If MUF.Value = False And HDP.Value = False And LIGHT.Value = False Then
MsgBox "Veuillez selectionner le format"
Else
'-------- 2/ déblocage feuille concerné
' ---- si pas de valeur vide, on envoi
Dim no_ligne As Integer
Dim no_comd As String * 4
'*********************************** NE PAS UTILISER
'------------------ définition de la feuille à envoyer les données
'ThisWorkbook.Worksheets(LABEL_MOIS.Caption).visible = True
'ThisWorkbook.Worksheets(LABEL_MOIS.Caption).Activate
'************************ NE PAS UTILISER
'------------------ OUVERTURE DE LA FEUILLE BD TPS ARRET
ThisWorkbook.Worksheets("BD CONTAINERS").visible = True
ThisWorkbook.Worksheets("BD CONTAINERS").Activate
' --- Dévérouillage feuille
Dim w As Worksheet
For Each w In ActiveWorkbook.Sheets
w.Unprotect Password:="AZERTY"
Next
'actualisation de l'horloge
ThisWorkbook.Worksheets("parametre").Range("B11") = Time
'******- a modifier : intégration sur la feuille "mois" en fonction du mois
'------------- 3/ Confirmation de l'envoi des données
'message de confirmation
If MsgBox("Confirmez-vous ces information ?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then
no_ligne = Range("A65536").End(xlUp).Row + 1 'placement du nouvel enregistrement en dessous
temp = ""
Application.ScreenUpdating = True
'--------------- 4/ Formatage des données
'---- suivant si MUF HDP LIGHT coché, inscrit la valeur dans colonne
For Each c In Me.Frame_format.Controls
If c.Value = True Then
matiere = c.Caption
End If
Next c
' ---- Importation donnée
Cells(no_ligne, 1) = CDate(LABEL_DATE.Caption) 'colonne A Date
Cells(no_ligne, 2) = matiere 'colonne B matiere
Cells(no_ligne, 3) = TextBox_article.Value 'colonne C Code article
Cells(no_ligne, 4) = TextBox_heure.Value 'colonne D Heure de fin
Cells(no_ligne, 5) = TextBox_numero_lot.Value 'colonne E N° lot
Cells(no_ligne, 6) = TextBox_numero_containers.Value 'colonne F N° containers
Cells(no_ligne, 7) = TextBox_nbr_pains.Value 'Colonne G N° de pains
Cells(no_ligne, 8) = TextBox_poids.Value 'colonne H poids
Cells(no_ligne, 9) = TextBox_Petits_Pains.Value 'colonne I petits pains
Cells(no_ligne, 10) = TextBox_Corcieux.Value 'colonne J corcieux
'--- message confirmation
MsgBox ("Vos données ont été ajoutées "), vbOKOnly, "Confirmation"
End If
'--------- 5/ vérouillage feuille
'------------ vérouillage feuille
For Each w In ActiveWorkbook.Sheets
w.EnableAutoFilter = True
w.EnableOutlining = True
w.Protect Contents:=True, Password:="AZERTY", UserInterfaceOnly:=True
Next
' RAZ du formulaire actif
ThisWorkbook.Worksheets("LANCEMENT FORMULAIRE").visible = True
ThisWorkbook.Worksheets("LANCEMENT FORMULAIRE").Activate
ThisWorkbook.Worksheets("parametre").Range("B11") = Time
'FORMULAIRE_B.Show
End If
End Sub
Private Sub btn_close1_click()
Unload Me
End Sub |
Partager