Bonjour à tous

J'aurais besoin de vos avis expert pour ce que je viens de produire.
Tout fonctionne (pour changer) sauf la phase compression que je n'ai pas encore testé. (d'ailleurs vos avis seront la bienvenue)

Je ne doute pas qu'il y ai des choses qui puissent être perfectionner c'est justement pour cela que je vous le soumets.

Merci d'avance

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
 
Private Sub UserForm_Initialize()
 
    Sheets("ref").Select
 
    Dim wbk1 As Workbook 
    Dim wbk2 As Workbook 
    Dim wbk3 As Workbook 
    Dim wbk4 As Workbook 
    Dim wbk5 As Workbook 
    Dim derlig As String 'derniere ligne de l'onglet selectionné
    Dim derliga As String 'dernier ligne tableau filtré
    Dim onglet As String 'onglet de source et destination dans l'autre fichier
    Dim ws As Worksheet
 
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
 
'remplissage du combobox répertoire
    With ws
    ComboBox1.Clear
    Dim i As Range
    Set i = .Range("B3:B22")
    End With
 
'remplissage du combobox système
    With ws
    ComboBox8.Clear
    Dim k As Range
    Set k = .Range("J4:J6")
    End With
 
    ComboBox1.List = i.Value
    ComboBox8.List = k.Value
 
End Sub
 
Private Sub Aide_Click()
 
    UserForm2.Show 'affiche un userform avec les indications pour remplir le formulaire
 
End Sub
 
Private Sub ComboBox2_Change()
    'charge le combobox de fichier present dans le classeur et donc sur le réseau
    Dim ws As Worksheet
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
    ws.Range("C28").Value = ComboBox2.Value
 
End Sub
 
Private Sub ComboBox9_Change()
    'indique le répertoire de destination du fichier
    Dim ws As Worksheet
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
    ws.Range("C27").Value = ComboBox9.Value
 
End Sub
    'pas encore testé
Private Sub Compression_Click()
    'deplace les fichiers archivés dans un repertoire de la semaine correspondante
    'puis compresse le répertoire
    Dim chemin As String
    Dim zipp As String
    Dim derliga As String
    Dim Doss As String
    Dim ws1 As Worksheet
    Dim cell As Range
    Dim fich As String
 
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
 
    Dim Source, Destination, MyHex, MyBinary, i
    Dim oShell, oApp, oFolder, oCTF, oFile
    Dim oFileSys
 
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
    ws.Range("I33").Value = TextBox13.Value
 
    Doss = ws.Range("H38").Value
    If Dir(Doss, vbDirectory) = "" Then
    MkDir Doss
    End If
 
    Workbooks.Open Filename:=ws.Range("D36").Value
    Set wbk3 = Workbooks(wbk1.ws.Range("C36").Value)
 
    wbk1.ws.Range("J36").Copy Destination:=wbk3.Sheets("ref").Range("H29")
    wbk1.ws.Range("J37").Copy Destination:=wbk3.Sheets("ref").Range("H30")
 
    For Each ws1 In Sheets
    If Sheet.Name = "ref" Then Next ws1
    End If
    If Sheet.Name = "sommaire" Then Next ws1
    End If
 
    derliga = Range("B" & Rows.Count).End(xlUp).Row
    Range("M2").AutoFill Destination:=Range("M2:MK" & derliga)
 
    For Each cell In Range("M2:M" & derliga)
    If cell.Value = 1 Then
    cell.Offset(0, -12).Value = zipp
    fich = cell.Offset(0, -11).Value
 
    FileCopy cell.Offset(0, -10).Value, wbk1.ws.Range("h41").Value & fich
 
    End If
 
    Next ws1
 
    Source = wbk1.ws.Range("H38").Value
    Destination = wbk1.ws.Range("H39").Value
 
    MyHex = _
    Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
    For i = 0 To UBound(MyHex)
        MyBinary = MyBinary & Chr(MyHex(i))
    Next
 
    Set oShell = CreateObject("WScript.Shell")
    Set oFileSys = CreateObject("Scripting.FileSystemObject")
 
    Set oCTF = oFileSys.CreateTextFile(Destination, True)
    oCTF.Write MyBinary
    oCTF.Close
    Set oCTF = Nothing
 
    Set oApp = CreateObject("Shell.Application")
 
    Set oFolder = oApp.Namespace(Source)
    If Not oFolder Is Nothing Then _
        oApp.Namespace(Destination).CopyHere oFolder.Items
 
    Set oFile = Nothing
    On Error Resume Next
 
    Do While (oFile Is Nothing)
 
        Set oFile = oFileSys.OpenTextFile(Destination, ForAppending, False)
 
        If Err.Number <> 0 Then
            Err.Clear
        End If
    Loop
 
    Set oFile = Nothing
    Set oFileSys = Nothing
 
    wbk3.Close True
 
 
End Sub
    'testé OK
Private Sub reset_Click()
 
    'remet à zéro toutes les cellules de saisie
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
    ws.Range("C27").ClearContents
    ws.Range("C26").ClearContents
    ws.Range("C32").ClearContents
    ws.Range("C41").ClearContents
    ws.Range("C42").ClearContents
    ws.Range("C46").ClearContents
    ws.Range("D46").ClearContents
 
End Sub
    'testé OK
Private Sub consulter_Click()
 
    Dim ws As Worksheet
    For Each ws In Worksheets
    If ws.FilterMode = True Then ws.ShowAllData
    Next ws
 
    UserForm1.Hide
    Sheets("sommaire").Select
 
End Sub
    'testé OK
Private Sub fermer_Click()
 
    Set wbk1 = ThisWorkbook
    UserForm1.Hide
    Dim ws As Worksheet
    For Each ws In Worksheets
    If ws.FilterMode = True Then ws.ShowAllData
    Next ws
 
    wbk1.Close True
 
End Sub
    'testé OK
Private Sub revisable_Click()
 
    Dim cell As Range
    Dim chemin As String
    Dim nomfichier As String
    Dim derliga As String
 
    Set wbk1 = ThisWorkbook
    Dim ws As Worksheet
    Set ws = wbk1.Sheets("ref")
 
    Workbooks.Open Filename:=ws.Range("C38").Value
    Set wbk5 = Workbooks(wbk1.ws.Range("C38").Value)
 
    wbk1.Activate
 
    For Each cell In ws.Range("B3:B22")
    wbk1.Activate
    onglet = cell.Value
    Sheets(onglet).Select
    derlig = Range("a" & Rows.Count).End(xlUp).Row
    ActiveSheet.Range("$a$2:$j$" & derlig).AutoFilter field:=10, Criteria1:="1"
 
    If Cells(Rows.Count, 1).End(xlUp).Row <> 0 Then
    Range("A1:J" & derlig).SpecialCells(xlVisible).Copy
    End If
 
    wbk5.Activate
    Sheets(onglet).Select
    Range("A1").PasteSpecial Paste:=xlPasteValues, Transpose:=False
    derliga = Range("a" & Rows.Count).End(xlUp).Row
    Range("C2:c" & derliga).NumberFormat = "dd/mm/yyyy"
 
    Columns("A:A").EntireColumn.AutoFit
    Range("A1:J" & derliga).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    Rows("1:1").Select
    Selection.RowHeight = 28.2
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
 
    Next cell
 
    chemin = ws.Range("D39").Value
    wbk5.SaveAs chemin
    wbk5.Close False
 
End Sub
    'testé OK
Private Sub ComboBox1_Change()
 
    Dim ws As Worksheet
 
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
 
    onglet = ComboBox1.Value
    Range("C26").Value = onglet
    Sheets(onglet).Select
 
    With Sheets(onglet)
    derliga = Range("a" & Rows.Count).End(xlUp).Row
    ComboBox2.Clear
    Dim n As Range
    Set n = .Range("A2:A" & derliga)
    End With
 
    ComboBox2.List = n.Value
 
    ws.Select
 
    ComboBox9.Clear
    Dim m As Range
    If onglet = Range("B3").Value Then
    Set m = Range("B52:B58")
    End If
    If onglet = Range("B4").Value Then
    Set m = Range("c52:c58")
    End If
    If onglet = Range("B5").Value Then
    Set m = Range("d52:d56")
    End If
    If onglet = Range("B6").Value Then
    Set m = Range("e52:e75")
    End If
    If onglet = Range("B7").Value Then
    Set m = Range("f52:f54")
    End If
    If onglet = Range("B8").Value Then
    Set m = Range("g52:g55")
    End If
    If onglet = Range("B9").Value Then
    Set m = Range("h52:h343")
    End If
    If onglet = Range("B10").Value Then
    Set m = Range("i52:i68")
    End If
    If onglet = Range("B11").Value Then
    Set m = Range("j52:j67")
    End If
    If onglet = Range("B12").Value Then
    Set m = Range("k52:k54")
    End If
    If onglet = Range("B13").Value Then
    Set m = Range("l52:l56")
    End If
    If onglet = Range("B14").Value Then
    Set m = Range("m52:m66")
    End If
    If onglet = Range("B15").Value Then
    Set m = Range("n52:n54")
    End If
    If onglet = Range("B16").Value Then
    Set m = Range("o52:o140")
    End If
    If onglet = Range("B17").Value Then
    Set m = Range("p52")
    End If
    If onglet = Range("B18").Value Then
    Set m = Range("q52:r53")
    End If
    If onglet = Range("B19").Value Then
    Set m = Range("r52:r62")
    End If
    If onglet = Range("B20").Value Then
    Set m = Range("s52:s53")
    End If
    If onglet = Range("B21").Value Then
    Set m = Range("t52:t63")
    End If
    If onglet = Range("B22").Value Then
    Set m = Range("u52:u60")
    End If
 
    ComboBox9.List = m.Value
 
End Sub
    'testé OK
Private Sub Edition_Click()
 
    Dim fichierR As String
    Dim c As Range
    fichierR = ComboBox2.Value
    onglet = ComboBox1.Value
    Set wbk1 = ThisWorkbook
    Sheets(onglet).Select
 
    Set c = wbk1.Sheets(onglet).Cells.Find(what:=fichierR)
    c.Select
    c.Offset(0, 3).Value = TextBox1.Value
    c.Offset(0, 4).Value = TextBox2.Value
    c.Offset(0, 5).Value = TextBox3.Value
    c.Offset(0, 6).Value = TextBox4.Value
 
End Sub
    'testé OK
Private Sub miseajour_Click()
 
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
    ws.Range("C46").Value = TextBox8.Value
 
    Dim fichierR As String
    Dim c As Range
    Dim c2 As Range
    Dim RepO As String
    Dim RepD As String
    Dim chemin As String
    Dim derlig As String
 
    fichierR = ComboBox2.Value
    onglet = ComboBox1.Value
    Set wbk1 = ThisWorkbook
    Sheets(onglet).Select
 
    Set c = wbk1.Sheets(onglet).Cells.Find(what:=fichierR)
    c.Select
    ws.Range("D46").Value = c.Value
    chemin = ws.Range("D47").Value
 
    FileCopy c.Offset(0, 1).Value, chemin
 
    c.Offset(0, 7).Value = TextBox7.Value
    Range(c, c.Offset(0, 8)).Copy
 
    Workbooks.Open Filename:=ws.Range("D36").Value
    Set wbk3 = Workbooks(wbk1.ws.Range("C36").Value)
 
    Sheets(onglet).Select
    Range("B1").End(xlUp)(2, 1).PasteSpecial Paste:=xlPasteValues, Transpose:=False
    Set c2 = wbk3.Sheets(onglet).Cells.Find(what:=fichierR)
    c2.Offset(0, 1).Value = chemin
    c2.Offset(0, 7).NumberFormat = "dd/mm/yyyy"
    derlig = Range("b" & Rows.Count).End(xlUp).Row
    Range("k2").AutoFill Destination:=Range("K2:K" & derlig)
 
    wbk3.Close True
 
    wbk1.Sheets(onglet).Select
 
    Kill c.Offset(0, 1).Value
 
    c.EntireRow.Delete
 
    FileCopy ws.Range("C33").Value, Range("E33").Value
    ws.Range("C32").Copy Destination:=Sheets(onglet).Range("A1").End(xlUp)(2, 1)
    ws.Range("E33").Copy Destination:=Sheets(onglet).Range("B1").End(xlUp)(2, 1)
 
    Kill ws.Range("c33").Value
    Sheets(onglet).Range("C1").End(xlUp)(2, 1).Value = TextBox6.Value
 
 
End Sub
    'testé OK
Private Sub ajout_Click()
 
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
    onglet = ComboBox1.Value
 
    FileCopy ws.Range("C33").Value, ws.Range("E33").Value
 
    ws.Range("C32").Value = TextBox12.Value
    Sheets(onglet).Range("A1").End(xlUp)(2, 1).Value = TextBox12.Value
    Sheets(onglet).Range("I1").End(xlUp)(2, 1).Value = ComboBox8.Value
 
    Kill ws.Range("C33").Value
 
End Sub
    'testé OK
Private Sub Archivage_Click() 'suppression du fichier de modèle NO
 
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
    ws.Range("C46").Value = TextBox8.Value
 
    Dim fichierR As String
    Dim c As Range
    Dim c2 As Range
    Dim RepO As String
    Dim RepD As String
    Dim chemin As String
    Dim derlig As String
 
    fichierR = ComboBox2.Value
    onglet = ComboBox1.Value
    Set wbk1 = ThisWorkbook
    Sheets(onglet).Select
 
    Set c = wbk1.Sheets(onglet).Cells.Find(what:=fichierR)
    c.Select
    ws.Range("D46").Value = c.Value
    chemin = ws.Range("D47").Value
 
    FileCopy c.Offset(0, 1).Value, chemin
 
    c.Offset(0, 7).Value = TextBox7.Value
    Range(c, c.Offset(0, 8)).Copy
 
    Workbooks.Open Filename:=ws.Range("D36").Value
    wbk1.Activate
    Set wbk3 = Workbooks(ws.Range("C36").Value)
    wbk3.Activate
    Sheets(onglet).Select
    Range("B1").End(xlUp)(2, 1).PasteSpecial Paste:=xlPasteValues, Transpose:=False
    Set c2 = wbk3.Sheets(onglet).Cells.Find(what:=fichierR)
    c2.Offset(0, 1).Value = chemin
    c2.Offset(0, 7).NumberFormat = "dd/mm/yyyy"
    derlig = Range("b" & Rows.Count).End(xlUp).Row
    If derlig > 2 Then
    Range("k2").AutoFill Destination:=Range("K2:K" & derlig), Type:=xlFillDefault
    Range("k2:k" & derlig).Select
    End If
    Range("D2:E" & derlig).NumberFormat = "dd/mm/yyyy"
 
    wbk3.Close True
 
    wbk1.Activate
 
    ws.Select
 
    Kill c.Offset(0, 1).Value
 
    c.EntireRow.Delete
 
End Sub
    'testé OK
Private Sub recherche_Click()
 
    Dim ws As Worksheet
    Dim cell As Range
    Dim chemin As String
    Dim nomfichier As String
    Dim derligb As String
    Dim ws2 As Worksheet
 
    Set wbk1 = ThisWorkbook
    Set ws = wbk1.Sheets("ref")
    ws.Select
 
    Range("C41").Value = TextBox9.Value
    Range("C42").Value = TextBox8.Value
 
    Range("C42").Copy
 
    Workbooks.Open Filename:=Range("D35").Value
    Sheets("ref").Select
    Range("D6").PasteSpecial Paste:=xlPasteAll, Transpose:=False
    wbk1.Activate
    ws.Select
    Range("C42").Copy
    Workbooks.Open Filename:=Range("D36").Value
    Sheets("ref").Select
    Range("C33").PasteSpecial Paste:=xlPasteAll, Transpose:=False
    wbk1.Activate
    ws.Select
 
    Workbooks.Open Filename:=Range("D37").Value
    wbk1.Activate
    ws.Select
 
    Set wbk2 = Workbooks(ws.Range("C35").Value)
    Set wbk3 = Workbooks(ws.Range("C36").Value)
    Set wbk4 = Workbooks(ws.Range("C37").Value)
 
    wbk2.Activate
 
    For Each cell In Sheets("ref").Range("B11:B26")
    onglet = cell.Value
    wbk2.Activate
    Sheets(onglet).Select
    derliga = Range("A" & Rows.Count).End(xlUp).Row
 
    ActiveSheet.Range("$a$2:$i$" & derliga).AutoFilter field:=9, Criteria1:="1"
    If Cells(Rows.Count, 1).End(xlUp).Row <> 1 Then
    Range("A2:i" & derliga).SpecialCells(xlVisible).Copy
 
    wbk4.Activate
    Sheets("avant_2018").Select
    Range("A1").End(xlUp)(2, 1).PasteSpecial Paste:=xlPasteValues, Transpose:=False
    End If
 
Next cell
 
    wbk2.Activate
 
    For Each ws2 In Worksheets
    If ws.FilterMode = True Then ws.ShowAllData
    Next ws2
 
    wbk2.Close False
 
    wbk4.Activate
 
    derliga = Range("A" & Rows.Count).End(xlUp).Row
    Range("C2:D" & derliga).NumberFormat = "dd/mm/yyyy"
    Range("h2:h" & derliga).NumberFormat = "dd/mm/yyyy"
 
    Columns("A:A").EntireColumn.AutoFit
    Range("A1:J" & derliga).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    Rows("1:1").Select
    Selection.RowHeight = 28.2
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
 
    wbk3.Activate
 
    For Each cell In Sheets("ref").Range("B3:B22")
 
    onglet = cell.Value
    Sheets(onglet).Select
    derliga = Range("A" & Rows.Count).End(xlUp).Row
    ActiveSheet.Range("$a$2:$l$" & derliga).AutoFilter field:=11, Criteria1:="1"
    If Cells(Rows.Count, 1).End(xlUp).Row <> 1 Then
    Range("A2:l" & derliga).SpecialCells(xlVisible).Copy
 
    wbk4.Activate
    Sheets(onglet).Select
    Range("A1").End(xlUp)(2, 1).PasteSpecial Paste:=xlPasteValues, Transpose:=False
    derligb = Range("a" & Rows.Count).End(xlUp).Row
    Range("C2:D" & derligb).NumberFormat = "dd/mm/yyyy"
 
    Columns("A:A").EntireColumn.AutoFit
    Range("A1:l" & derligb).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    Rows("1:1").Select
    Selection.RowHeight = 28.2
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
 
    End If
 
    Next cell
 
    wbk3.Close False
 
    chemin = wbk1.Sheets("ref").Range("C43").Value
    wbk4.SaveAs chemin
 
    wbk4.Close False
 
    wbk1.Activate
 
End Sub