Thank you for your reply.
My code is very simple, I used the Macro Recorder to do the code for me and then customized the SQL statement to my needs.
origemSQL = "My Path Here"
comSQL = "SELECT DISTINCT TDadosRecolha.Circuito, TDadosRecolha.Mês, TDadosRecolha.`Tipo Deposição`, TDadosRecolha.Fileira, TDadosRecolha.`Frequência Recolha`" & Chr(13) & _
"FROM `" & origemSQL & "`.TDadosRecolha TDadosRecolha"
origemSQL = "ODBC;DSN=Ficheiros Excel;DBQ=" & origemSQL & ";DriverId=790;MaxBufferSize=2048;PageTimeout=5;"
With ActiveSheet.QueryTables.Add(Connection:=origemSQL, _
Destination:=Range("A1"))
.CommandText = comSQL
.Name = "Consulta 2 de Ficheiros Excel"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
Bookmarks