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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
| Public N As Integer
Public C As Integer
Public R As Integer
Public Lot As Long
Public TROUVE As Boolean
Public ENREGAUTO As Boolean
Public FERMETURE As Boolean
Public LOTCHRCHE As Range
Public Debut As Date
Public Jour As Variant
Public MODIF As Boolean
Sub Export()
Dim T As Boolean
T = False
If Not (ThisWorkbook.ReadOnly) Then
On Error GoTo Fin
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Workbooks("SUIVI_LOTS.xls").Save
Calculate
'Comptage du nombre de ligne dans la liste auto-qualité
Comptage
'Comptage des lots non-auto-qualité dans la liste CQ
Dim i As Integer
i = 4
'Tri des lots non-auto-qualité dans la liste CQ
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("A4:BV2000").Sort Key1:=Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("B4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
i = Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Cells(1, 2).Value + 4
'Transfert des données Stérilité vers Programme CQ
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("A" & i & ":C2000").ClearContents
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("A" & i & ":C" & i + N - 3).Value = ThisWorkbook.Sheets("Liste").Range("B" & 3 & ":D" & N).Value
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("E" & i & ":F2000").ClearContents
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("E" & i & ":F" & i + N - 3).Value = ThisWorkbook.Sheets("Liste").Range("E" & 3 & ":F" & N).Value
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("H" & i & ":H2000").ClearContents
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("H" & i & ":H" & i + N - 3).Value = ThisWorkbook.Sheets("Liste").Range("H" & 3 & ":H" & N).Value
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("J" & i & ":N2000").ClearContents
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("J" & i & ":N" & i + N - 3).Value = ThisWorkbook.Sheets("Liste").Range("J" & 3 & ":N" & N).Value
Workbooks("SUIVI_LOTS.xls").Save
T = True
End If
Fin:
If T = False Then
X = MsgBox("Le transfert automatique des données vers le CQ a échoué.", vbExclamation)
End If
End Sub
Sub Comptage()
N = ThisWorkbook.Worksheets("Liste").Cells(1, 16).Value
N = N + 3
End Sub
'Saisie d'un nouveau lot
Sub Macro1()
Application.ScreenUpdating = False
Worksheets("Planning").Unprotect Password:="123456"
Worksheets("Liste").Unprotect Password:="123456"
MODIF = True
R = 5
Nouvelle_Saisie.Show
MODIF = False
Worksheets("Planning").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="123456"
Worksheets("Liste").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="123456"
End Sub
'Modification de la date de fin et/ou modification du statut du dossier
Sub Macro2()
Application.ScreenUpdating = False
If R >= 5 And R <= 50 Then
Worksheets("Planning").Unprotect Password:="123456"
Worksheets("Liste").Unprotect Password:="123456"
MODIF = True
DateFin.Show
ActiveSheet.Cells(1, C).Select
MODIF = False
Worksheets("Planning").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="123456"
Worksheets("Liste").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="123456"
End If
End Sub
' MAJ de la date de fin réelle + statut du dossier
Sub Macro_Fin()
Application.ScreenUpdating = False
Dim i, j As Integer
j = 5
TROUVE = False
'Recherche du jour correspondant
If C >= 2 And C <= 8 Then
C = 2
ElseIf C >= 9 And C <= 15 Then
C = 9
ElseIf C >= 16 And C <= 22 Then
C = 16
ElseIf C >= 23 And C <= 29 Then
C = 23
ElseIf C >= 30 And C <= 36 Then
C = 30
ElseIf C >= 37 And C <= 43 Then
C = 37
ElseIf C >= 44 And C <= 50 Then
C = 44
End If
If (Worksheets("Planning").Cells(R, C) = VIDE And Lot <> VIDE) Or (Not IsEmpty(LOTCHRCHE) And Lot <> 0) Then
While Worksheets("Planning").Cells(j, C + 1) <> VIDE
If Worksheets("Planning").Cells(j, C + 1) = Lot Or Worksheets("Planning").Cells(j, C + 1) = LOTCHRCHE.Value Then
R = j
TROUVE = True
GoTo Fin
End If
j = j + 1
Wend
j = 5
Else
TROUVE = True
End If
Fin:
End Sub
Sub Priorities()
Application.ScreenUpdating = False
Dim A As Integer
Dim B As Integer
Dim C As Integer
Workbooks("SUIVI_LOTS.xls").Save
A = Worksheets("Liste").Cells(1, 16).Value
'Nb de lots non autoqualité
B = Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Cells(1, 2).Value
'Nb de lots autoqualité
C = Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Cells(1, 3).Value
Worksheets("Liste").Unprotect Password:="123456"
'Tri des lots non-auto-qualité dans la liste CQ
Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("A4:BV2000").Sort Key1:=Workbooks("SUIVI_LOTS.xls").Sheets("Liste PETRI").Range("B4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
If ThisWorkbook.ReadOnly Then
ENREGAUTO = True
End If
MODIF = True
If A <> 0 Then
Worksheets("Liste").Range("A3:A" & 2 + A).Value = Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("D" & 4 + B & ":D" & 4 + C).Value
Worksheets("Liste").Range("O3:O" & 2 + A).Value = Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("BQ" & 4 + B & ":BQ" & 4 + C).Value
End If
Worksheets("Liste").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="123456"
Worksheets("Urgences").PivotTables("Tableau croisé dynamique1").RefreshTable
ENREGAUTO = True
MODIF = False
If Not (ThisWorkbook.ReadOnly) Then
ThisWorkbook.Save
ENREGAUTO = False
End If
End Sub
Sub Archivage()
Dim Chemin1, Chemin2, Chemin3 As Variant
Chemin1 = Workbooks("SUIVI_LOTS.xls").Path & "\" & Workbooks("SUIVI_LOTS.xls").Name
Chemin2 = Worksheets("Paramètres").Cells(16, 3).Value
Chemin3 = ThisWorkbook.Path
'Archivage permis seulement entre 20:30 et 5:00 pour réduire le risque de conflit
If Not (ThisWorkbook.ReadOnly) And ((Time > 0.84375 And Ime < 0.989999999) Or (Time > 0.000000001 And Time < 0.16666667)) And Chemin1 = Chemin2 And Chemin3 = "X:\_SUIVI DE LOTS\01-AUTOQUALITE" Then
Application.ScreenUpdating = False
Application.DisplayAlerts = False
X = MsgBox("L'opération d'archivage est une opération critique et peut prendre plusieurs minutes. Merci ne pas effectuer d'autres tâches sur le poste pendant cette opération pour assurer son bon déroulement.", vbExclamation)
'================================== ARCHIVAGE DES DONNEES T&F ==================================================================================================================================================================
'Vérifier que le fichier stérilité T&F n'est pas déjà ouvert
Dim lWorkbook As Workbook
Dim Found, Ouvert As Boolean
Found = False
For Each lWorkbook In Workbooks
If lWorkbook.Name = "Saisie Stérilité T&F.xls" Then
Found = True
Exit For
End If
Next
If Found = False Then
Workbooks.Open Filename:= _
"" & Worksheets("Paramètres").Cells(19, 3) & "", WriteResPassword:="sandrine"
'S'il n'est pas en lecture seule, lancer l'archivage
If Not (Workbooks("Saisie Stérilité T&F.xls").ReadOnly) Then
Workbooks("Saisie Stérilité T&F.xls").Worksheets("Liste").Activate
Application.Run "'Saisie Stérilité T&F.xls'!Archivage"
Workbooks("SUIVI_LOTS.xls").Save
Workbooks("Saisie Stérilité T&F.xls").Save
Workbooks("Saisie Stérilité T&F.xls").Close
Else
'Dans le cas où le fichier T&F est ouvert
Workbooks("Saisie Stérilité T&F.xls").Close
Ouvert = True
X = MsgBox("Le fichier de saisie du secteur Tubes & Flacons étant actuellement en cours d'utilisation, l'archivage ne peut pas être effectué. Merci de réessayer ultérieurement", vbCritical)
GoTo Fin
End If
End If
'================================== ARCHIVAGE DES DONNEES PETRI ==================================================================================================================================================================
Dim i, j As Integer
i = 3
j = 0
Dim Nom As Variant
'Enregistrement des différents fichiers + MAJ des statuts des lots
ThisWorkbook.Activate
Priorities
'Suppression des données dans le fichier Autoqualité
MODIF = True
Worksheets("Liste").Unprotect Password:="123456"
While Worksheets("Liste").Cells(i, 15).Value = "" And i < 2000
i = i + 1
Wend
If i <> 2000 Then
Selection.AutoFilter Field:=15, Criteria1:="<>"
Worksheets("Liste").Range("A" & i & ":B2001, D" & i & ":F2001, H" & i & ":H2001, J" & i & ":O2001").ClearContents
Selection.AutoFilter Field:=15
Worksheets("Liste").Range("A3:O1499").Select
Selection.Sort Key1:=Range("C3"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Worksheets("Liste").Range("A1").Select
Worksheets("Liste").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="123456"
Else
Worksheets("Liste").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="123456"
X = MsgBox("Opération d'archivage terminée avec succès", vbOKOnly)
GoTo Fin
End If
'Archivage des données dans le fichier Suivi_Lots --> Liste PETRI
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Activate
Application.Run "SUIVI_LOTS.xls!Archives_Debut"
'Enlever le partage pendant l'archivage et éviter un conflit si quelqu'un d'autre l'avait laissé ouvert
Workbooks("SUIVI_LOTS.xls").ExclusiveAccess
i = 4
While Worksheets("Liste PETRI").Cells(i, 69).Value = "" And i < 3000
i = i + 1
Wend
If i <> 3000 Then
'Ouverture du fichier d'Archives
Workbooks.Open Filename:= _
"" & ThisWorkbook.Worksheets("Paramètres").Cells(18, 3) & "", WriteResPassword:="history"
Nom = ActiveWorkbook.Name
Workbooks(Nom).Worksheets("Liste PETRI").Activate
j = Worksheets("Liste PETRI").Cells(1, 3).Value + 4
'Copie des données dans le fichier d'archives
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Activate
' A supprimer dans la version définitive
Columns("A:BV").Select
Selection.EntireColumn.Hidden = False
Selection.AutoFilter Field:=69, Criteria1:="<>"
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("A" & i & ":D3001").Copy
Workbooks(Nom).Activate
Range("A" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("E" & i & ":G3001").Copy
Workbooks(Nom).Activate
Range("F" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("J" & i & ":L3001").Copy
Workbooks(Nom).Activate
Range("I" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("O" & i & ":O3001").Copy
Workbooks(Nom).Activate
Range("L" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("P" & i & ":S3001").Copy
Workbooks(Nom).Activate
Range("N" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("U" & i & ":AD3001").Copy
Workbooks(Nom).Activate
Range("R" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("AF" & i & ":AO3001").Copy
Workbooks(Nom).Activate
Range("AB" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("AQ" & i & ":AZ3001").Copy
Workbooks(Nom).Activate
Range("AL" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("BB" & i & ":BL3001").Copy
Workbooks(Nom).Activate
Range("AV" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("BM" & i & ":BP3001").Copy
Workbooks(Nom).Activate
Range("BH" & j).Select
Selection.PasteSpecial Paste:=xlValues
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("BQ" & i & ":BV3001").Copy
Workbooks(Nom).Activate
Range("BM" & j).Select
Selection.PasteSpecial Paste:=xlValues
'Remise en forme de l'onglet Liste PETRI
Workbooks("SUIVI_LOTS.xls").Activate
Worksheets("Liste PETRI").Activate
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("A" & i & ":F3001, H" & i & ":H3001, J" & i & ":S3001, U" & i & ":AD3001, AF" & i & ":AO3001, AQ" & i & ":AZ3001, BB" & i & ":BV3001").ClearContents
Selection.AutoFilter Field:=69
Workbooks("SUIVI_LOTS.xls").Worksheets("Liste PETRI").Range("A4:BV2999").Sort Key1:=Range("B4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
' A supprimer dans la version définitive
Application.Run "SUIVI_LOTS.xls!Mise_en_Forme_PETRI"
'Enregistrer immédiatement pour limiter les risques de conflits
ThisWorkbook.Activate
ThisWorkbook.Save
Workbooks(Nom).Activate
Application.Run Nom & "!Mise_en_Forme_PETRI"
Workbooks(Nom).Save
Workbooks(Nom).Close
End If
MODIF = False
X = MsgBox("Opération d'archivage terminée avec succès", vbOKOnly)
Workbooks("SUIVI_LOTS.xls").KeepChangeHistory = False
Workbooks("SUIVI_LOTS.xls").SaveAs Filename:= _
"\\Frmant02\Ctrlbact\_SUIVI DE LOTS\SUIVI_LOTS.xls", AccessMode:=xlShared
Application.Run "SUIVI_LOTS.xls!Archives_Fin"
Application.Run "SUIVI_LOTS.xls!Supp_barre_boutons"
Application.Windows("SUIVI_LOTS.xls").Visible = False
Fin:
Else
If (Chemin1 <> Chemin2) Or Chemin3 <> "X:\_SUIVI DE LOTS\01-AUTOQUALITE" Then
X = MsgBox("Le fichier utilisé actuellement n'est pas placé au bon endroit. Veuillez fermer, puis réouvrir le fichier immédiatement.", vbCritical)
Else
X = MsgBox("L'archivage ne peut pas être effectué dans cette plage horaire de la journée", vbCritical)
End If
End If
End Sub |