Sub test()
Dim Cn As Object, Rst As Object, Texte_SQL2$, NomFeuille$, iValeur,Destination as range
set destination=[A1]' a modifier à ton gré
Fichier = Sheets("Parametres").Range("A2") 'verifier si le chemin est bien complet ici!!!!!!!!!!!!!!
Set Cn = New ADODB.Connection ' instanciation de l'object adodb.connection
On Error GoTo handler
With Cn
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Fichier & ";Extended Properties=""Excel 12.0;HDR=YES;"""
.Open
iValeur = "210013418"
NomFeuille = "Informations personnelles" 'verifier l'ortographe et la casse
Texte_SQL2 = "Select * FROM [" & NomFeuille & "$] Where [MATRICULE CEG] = " & iValeur
Set Rst = New ADODB.Recordset 'instanciation de l'object recordset
Set Rst = Cn.Execute(Texte_SQL2)
Destination.CopyFromRecordset Rst
'--- Fermeture connexion ---
.Close
End With
'destruction variables object de connection
Set Cn = Nothing: Set Rst = Nothing
handler:
MsgBox Err.Number & vbCrLf & Err.description
Err.Clear
On Error GoTo 0
Set Cn = Nothing: Set Rst = Nothing
End Sub