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
| Sub ImporterDates1()
Dim objShell As Object, objFolder As Object
Dim Chemin As String, fichier As String
Dim sheetName As String
Dim firstRow As Integer
Dim firstColumn As Integer
Dim maPlage As Range
Dim column As Integer
With Application
.ScreenUpdating = False
End With
firstRow = 5
firstColumn = 2
column = firstColumn
sheetName = "Feuil1"
Chemin = "C:\TEST\"
fichier = Dir(Chemin & "*.xls")
Do While Len(fichier) > 0
If fichier <> ThisWorkbook.Name Then
ThisWorkbook.Names.Add "Plage", _
RefersTo:="='[" & fichier & "]Feuil1'!$A$1:$A$5"
For Each NM In ThisWorkbook.Names
If Right(NM, 9) Like "$A$1:$A$5" Then
Set maPlage = NM.RefersToRange
column = firstColumn
For Each p In maPlage.Cells
Sheets(1).Cells(firstRow, column) = p.Value
column = column + 1
Next
firstRow = firstRow + 1
End If
Next
End If
fichier = Dir()
Loop
With Application
.ScreenUpdating = True
End With
End Sub |
Partager