Sub extractionValeurCelluleClasseurFerme()
Dim Source As ADODB.Connection
Dim Rst As ADODB.Recordset
Dim ADOCommand As ADODB.Command
Dim Fichier$, Cellule$, Feuille As Worksheet
Dim Plage(), Col()
Plage = Array("F4:H1000", "AO4:AP1000")
Col = Array(2, 5)
For i = 1 To Sheets.Count
Sheets(i).Rows("2:65536").Clear
Next
Fichier = Dir(ThisWorkbook.Path & "\*.xls")
Do While Fichier <> ""
If Fichier <> ThisWorkbook.Name Then
Set Source = New ADODB.Connection
Source.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ThisWorkbook.Path & "\" & Fichier & ";Extended Properties=""Excel 12.0;HDR=no;"";"
For Each Feuille In ActiveWorkbook.Worksheets
For i = 0 To 1
Cellule = Plage(i)
Set ADOCommand = New ADODB.Command
With ADOCommand
.ActiveConnection = Source
.CommandText = "SELECT * FROM [" & Feuille.Name & "$" & Cellule & "]"
End With
Set Rst = Source.Execute("[" & Feuille.Name & "$" & Cellule & "]")
With Feuille
.Cells(65536, Col(i)).End(3)(2).CopyFromRecordset Rst
End With
Next i
Rst.Close
Next
Source.Close
Set Source = Nothing
Set Rst = Nothing
Set ADOCommand = Nothing
End If
Fichier = Dir
Loop
Beep
End Sub