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
| Option Explicit
Dim fDep, f, i, lgn, derln
Sub Importer()
Application.ScreenUpdating = False
Set fDep = ActiveSheet
Range("A1").CurrentRegion.Offset(1, 0).ClearContents
MsgBox "Dans la fenêtre qui va s'ouvrir, chercher et sélectionner l'ensemble des fichiers dont il faut importer les données."
f = Application.GetOpenFilename(, , , , True)
For i = 1 To UBound(f)
Workbooks.Open (f(i))
ActiveWorkbook.Sheets("Part list").Select
Range("B4:M" & Range("B" & Rows.Count).End(xlUp).Row - 1).Copy
lgn = fDep.Range("R" & Rows.Count).End(xlUp)(2).Row
fDep.Range("R" & lgn).PasteSpecial xlPasteValues
Application.DisplayAlerts = False
ActiveWorkbook.Close False
Next i
derln = Range("R" & Rows.Count).End(xlUp).Row
Range("U2:U" & derln).Copy Range("A2")
Range("R2:R" & derln).Copy Range("B2")
Range("S2:S" & derln).Copy Range("C2")
Range("AC2:AC" & derln).Copy Range("D2")
Range("T2:T" & derln).Copy Range("H2")
Range("V2:V" & derln).Copy Range("I2")
Range("W2:W" & derln).Copy Range("J2")
Range("Y2:Y" & derln).Copy Range("K2")
Range("R2").CurrentRegion.ClearContents
Range("A1").Select
Cells.Select
ActiveSheet.Range("$A$1:$P$642").RemoveDuplicates Columns:=2, Header:=xlYes
End Sub |
Partager