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
|
Sub TRAITEMENT_PROPUBLIC_FDP_FDC()
Application.DisplayAlerts = True
Dim Cel As Range, plg As Range
Dim Derlig As Long
Dim Sh As Worksheet
Dim LePath As String
Application.ScreenUpdating = False
INSERTION_LIGNES
LePath = "\\172.16.0.210\ResolutionS\Mailing\2018\Mise Sous Pli\Press Maker\"
ClasseurActif = ActiveWorkbook.Name
RépertoireActif = ActiveWorkbook.Path & "\"
Application.Workbooks.Open LePath & "\ETAT DE STOCKS_AUTOMATE.xls" '
With Sheets("STOCK")
ligne = .Cells(Rows.Count, 3).End(xlUp).Row
.Range("b2:e" & ligne).Copy
End With
Workbooks(ClasseurActif).Activate
ActiveWorkbook.Worksheets.add
ActiveSheet.Name = "STOCK"
Range("A1").PasteSpecial (xlPasteValues)
Application.DisplayAlerts = False
Workbooks("ETAT DE STOCKS_AUTOMATE.xls").Close
Application.DisplayAlerts = True
Sheets("VPC STANDARD").Activate
With Sheets("STOCK")
For i = 2 To .Cells(.Rows.Count, 1).End(xlUp).Row
Set PlageRech = Sheets("VPC STANDARD").Range("A:A")
Set c = PlageRech.Find(.Cells(i, 2), lookat:=xlWhole)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
NUM_PARUTION = .Cells(i, 1)
POIDS_PARUTION = .Cells(i, 4)
ligne = Sheets("VPC STANDARD").Range("A" & .Rows.Count).End(xlUp).Row
Col = Sheets("VPC STANDARD").Cells(1, .Cells.Columns.Count).End(xlToLeft).Column
For x = 2 To ligne
If Cells(x, 1) = c Then
Sheets("VPC STANDARD").Cells(x, Col + 1) = NUM_PARUTION
Sheets("VPC STANDARD").Cells(x, Col + 2) = POIDS_PARUTION
End If
Next x
Set c = PlageRech.FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
Next i
End With
Set PlageRech = Nothing
With Sheets("VPC STANDARD")
.Cells(1, Col + 1) = "CODE DESIGNATION"
.Cells(1, Col + 2) = "POIDS PARUTION"
End With
Application.DisplayAlerts = False
Sheets("STOCK").Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = False
With Sheets(2)
Derlig = .Range("A" & .Rows.Count).End(xlUp).Row
DerCol = .Cells(1, .Cells.Columns.Count).End(xlToLeft).Column
For j = 2 To Derlig
.Cells(j, 1).Value = Application.Proper(SupprimerAccents(.Cells(j, 1)))
.Cells(j, 1).Value = Application.WorksheetFunction.Trim(.Cells(j, 1))
With Application
.Cells(j, 1).Value = .Clean(.Cells(j, 1).Value)
End With
Next
Set plg = .Range(.Cells(1, 1), .Cells(Derlig, DerCol))
plg(1).Resize(Derlig).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=.Range("Z1"), Unique:=True
For Each Cel In .Range("Z2:Z" & .Cells(Rows.Count, "Z").End(xlUp).Row)
If Cel <> "" Then
.[Z2] = Cel.Value
Set Sh = Sheets.add
plg.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.Range("Z1:Z2"), CopyToRange:=Sh.Range("A1")
Sh.Columns.EntireColumn.AutoFit
Sh.Move
ActiveWorkbook.SaveAs Filename:=RépertoireActif & "\" & Cel.Value & ".xls", FileFormat:=xlExcel8
ActiveWorkbook.Close
End If
Next Cel
.Columns("Z:Z").Clear
End With
Application.ScreenUpdating = True
End Sub |