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
| Dim f1, f2
Dim DerLig_L As Long, DerLig_C As Long
Sub Creation_Feuille_Container()
Application.ScreenUpdating = False
Set f1 = Sheets("Liste")
DerLig_L = f1.[D100000].End(xlUp).Row
Formule_Recup_Nom_Container
Filtrer_Container
f1.Columns(6).ClearContents
Set f1 = Nothing
End Sub
Sub Formule_Recup_Nom_Container()
Range("F4:F" & DerLig_L).FormulaR1C1 = "=IF(RC[-5]=""Container No:"",RC[-3],IF(RC[-5]=""Seal No :"",R[-1]C[-3],IF(AND(R[-1]C="""",OR(R[-2]C[-1]=""Description"",R[-1]C[-1]=""Description"")),R[-3]C[-3],R[-1]C)))"
Range("F4:F" & DerLig_L).Value = Range("F4:F" & DerLig_L).Value
End Sub
Sub Filtrer_Container()
ActiveSheet.AutoFilterMode = False
Range("F4").Select
If f1.AutoFilterMode Then
isOn = "On"
Else
isOn = "Off"
Selection.AutoFilter
End If
For Each C In f1.Range("F4:F" & DerLig_L)
On Error Resume Next
If f1.Cells(C.Row, "F") <> f1.Cells(C.Row - 1, "F") Then
f1.Range("A3:F" & DerLig_L).AutoFilter Field:=6, Criteria1:=C.Text
f1.Range("_FilterDataBase").Resize(, 11).SpecialCells(xlCellTypeVisible).Copy
If Err.Number = 0 Then
Sheets.Add(After:=Worksheets(Worksheets.Count)).Name = C.Text
Set f2 = Sheets(ActiveSheet.Name)
[A1].Select
ActiveSheet.Paste
DerLig_C = f2.[D100000].End(xlUp).Row
Tri
Formule_Somme_quantités
Suppression_Doublons
End If
On Error GoTo 0
End If
f1.ShowAllData
Set f2 = Nothing
Next C
End Sub
Sub Tri()
Range("A5:L" & DerLig_C).Sort [D5], 1
End Sub
Sub Formule_Somme_quantités()
Range("L5:L" & DerLig_C).FormulaR1C1 = "=SUMIF(C4,RC4,C8)"
Range("L5:L" & DerLig_C).Value = Range("L5:L" & DerLig_C).Value
End Sub
Sub Suppression_Doublons()
Cells.Select
ActiveSheet.Range("A5:L" & DerLig_C).RemoveDuplicates Columns:=4, Header:=xlYes
Range("H5:H" & DerLig_C).Value = Range("L5:L" & DerLig_C).Value
Columns("F:K").Delete
[F4] = "Q'ty" & Chr(10) & "(PCS)"
End Sub
Sub Supprimer_Feuilles_Containers()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For i = Sheets.Count To 1 Step -1
If Sheets(i).Name <> "Liste" Then Sheets(i).Delete
Next
End Sub |
Partager