Function requete_MYSQL(nom_feuille_la_requete, cellule_la_requete, nom_feuille_destination_resultat, cellule_destination_resultat)
' cellule_destination_resultat =non si on ne veut pas coller le resultat de la requete
'x = Application.Run("PERSONAL.XLAM!requete_MYSQL", "REQUETES", "B2", "BASE", "A11")
' REQUETE MYSQL
Dim Password As String
Dim SQLStr As String
Dim Server_Name As String
Dim User_ID As String
Dim Database_Name As String
Dim table_name As String
Set Rs = CreateObject("ADODB.Recordset")
Server_Name = "mon_serveur"
Database_Name = "ma_bdd"
User_ID = "Uid"
Password = "mon_mdp"
Set cn = CreateObject("ADODB.Connection")
cn.Open "Driver={MySQL ODBC 3.51 Driver};Server=" & _
Server_Name & ";Database=" & Database_Name & _
";Uid=" & User_ID & ";Pwd=" & Password & ";"
SQLStr = Sheets(nom_feuille_la_requete).Range(cellule_la_requete).Value
Rs.Open SQLStr, cn, adOpenStatic
'je colle le resultat dans la bonne cellule
If nom_feuille_destination_resultat <> "non" Then
Sheets(nom_feuille_destination_resultat).Range(cellule_destination_resultat).CopyFromRecordset Rs
cn.Close
Else
cn.Close
End If
End Function