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
|
Sub Importer()
' **********************************
' Importation des données
' **********************************
Dim ListeFichier As Variant
Dim MonClasseur As Workbook
Application.CutCopyMode = False
Application.ScreenUpdating = False
ListeFichier = Application.GetOpenFilename(Title:="Sélectionnez le Fournisseur", _
filefilter:="fichiers Excel(*.xls*),*xls*", buttontext:="Cliquez")
If ListeFichier <> False Then
Set MonClasseur = Application.Workbooks.Open(ListeFichier)
'On copie les données
Range(Cells(2, 1), Cells(Cells(Rows.Count, 1).End(xlUp).row, 28)).Copy
' on colle dans la feuille
If Feuil1.ListObjects("BaseArticles").ListColumns("Code GEN").Range.Cells(2, 1).Value = "" Then
Workbooks("Test-Outil.xlsm").Worksheets("Base").Range("BaseArticles").PasteSpecial Paste:=xlPasteValues
Else
Workbooks("Test-Outil.xlsm").Worksheets("Base").Range("BaseArticles").End(xlDown).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
End If
Application.DisplayAlerts = False
MonClasseur.Close
End If
End Sub |
Partager