Sub dh()
Dim Source As Object, Requete As Object
Dim onglet As String, Plage As String, Fichier As String
Dim texte_SQL As String
Fichier = "L:\CP.xls"
onglet = "CodeRép"
Plage = "A1:H10"
Set Source = CreateObject("ADODB.Connection")
Source.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Fichier & ";Mode=Read" & ";Extended Properties=""Excel 12.0;HDR=YES;"""
texte_SQL = "SELECT * FROM [" & onglet & "$" & Plage & "] WHERE " & plagerecherché & " LIKE " & valrecherche '& "ORDER BY [" & onglet & "$" & plagerecherché & "] desc"
Set Requete = CreateObject("ADODB.Recordset")
Set Requete = Source.Execute(texte_SQL)
remplaceusername = Requete.GetRows
Set Requete = Nothing
Set Source = Nothing
End Sub