Sub odbc()
'
' odbc Macro
'
'
Dim indicateursvba As String
indicateursvba = Range("indicateurs").Text
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"ODBC;DRIVER={MySQL ODBC 5.1 Driver};UID=pil_gener;SERVER=localhost;DATABASE=" & Range("base").Text & ";PORT=3306;" _
, Destination:=ActiveCell).QueryTable
.CommandText = Array( _
"SELECT " & indicateursvba & Chr(13) & "" & Chr(10) & "FROM " & Range("base").Text & Range("table_filtree").Text _
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = _
"Tableau_Lancer_la_requête_à_partir_de_pilote_macro" & Range("base").Value
.Refresh BackgroundQuery:=False
End With
End Sub