Prezados,
Olhei alguns tópicos, até achei alguns que me ajudaram como:
viewtopic.php?f=10&t=6249
Porem nao consigo executar.. continua dando erro
zData = Range("A1")
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"ODBC;DRIVER=SQL Server;SERVER=Banco;UID=user;;APP=Microsoft Office 2013;WSID=note" _
, Destination:=Range("$A$2")).QueryTable
.CommandType = 0
.CommandText = Array( _
"SELECT " & Chr(13) & "" & Chr(10) & "*" & Chr(13) & "" & Chr(10) & "FROM" & Chr(13) & "" & Chr(10) & "vw_bas_backlog" & Chr(13) & "" & Chr(10) & "WHERE estacao IN" & Chr(13) & "" & Chr(10) & "('ARC','ATL8','ATL9','ATLA','ATT3','BBOA','BBR2','BBR3','BDR1','BICA','BOBG','BOBH','BOBI','BOBK','BOBL','BOBM','BOT'," & Chr(13) & "" & Chr(10) & "'BRD2','BRD4','CAM','CEF2','" _
, _
"CEM','CIN','CITI','COP','CRRD','CTA4','CTAX','CTLB','CX02','ECM','EQUA','FLA','FLO','GVT'," & Chr(13) & "" & Chr(10) & "'IPA','IPBQ','JCCQ','LBCM','LBCN','LBCO','LBCP','LBCQ','LBCR','LBCS','LBCT','LBCU','LBCV','LBCY','LBCW','LBC" _
, _
"Z','LEB'," & Chr(13) & "" & Chr(10) & "'LEM','LNCC','MCT','MRED','NTEL','PGJ1','POL','PRA','SCD','SPR2','SRT','SUL','TIR','TGVM','TPA','TVO','UOL'," & Chr(13) & "" & Chr(10) & "'ALG2','AUST','BERO','CAEL','CIBA','CODIC','COSE','DQX','ENPE','GNDU','IBIC','I" _
, _
"GI','ILDM','ITSA','JPRI','MCO '," & Chr(13) & "" & Chr(10) & "'MESQ','MRU','NIU','NLP','NOCP','PBI','PDAN','PIBT','PNCO','POBL','POSP','QUEA','SBTO','SMI','SUNA','UERL','VIMU'," & Chr(13) & "" & Chr(10) & "'ACH','BCRE','BGR','BGU','BPN','BRB','BRF','CAC','" _
, _
"CARD','CGD','COL','COS','CSR','CTA6','END','END2','ENN','GAL','HNP'," & Chr(13) & "" & Chr(10) & "'IMPS','INT2','INTG','IRJ','JAB','JAC','JDA','JGU','JOHV','ASM','MAG','MAR','MDR','MGBS','MRCN','MSO','MSP','NAO','NHL'," & Chr(13) & "" & Chr(10) & "'FLE','P" _
, _
"AV','PGU','PIE','PQT','RAM','RMA','SCR','SCZ','SLC','SPB','TIJ','TIM','TIMA','TIRN','TMC2','VGL','VIB','VKY'," & Chr(13) & "" & Chr(10) & "'VMI','VVA','ZIC','ZIP','ZIS','ABA','ABV','ALV','ATDM','BAWO','BBN','BRM','BSP','BTJ','CD" _
, _
"RK','CDS','CEB','CVI','DTW','FRE','GBN','IBCC','JCP','LGM','MCA'," & Chr(13) & "" & Chr(10) & "'MLA','MPI','OPGL','PNB','RDB','RDC','RIT','RPA','TQA','VBT','VGD','VPAN','CRRD','ALV','BGR','B003','ETRB','IBM','R002','R007','R010'" _
, _
",'R011','R014','R009','R015','R017','R020','R022','R023','R024','R025','R026','R027'," & Chr(13) & "" & Chr(10) & "'R029','R031','R032','R036','R036','R037','R038','R039','R040','R041','R042','R044','R045','R046','R047','R048','" _
, _
"R050','R052'," & Chr(13) & "" & Chr(10) & "'R054','R055','R057','R058','R061','R062','R063','R064','R066','R067','R070','R071','R072','R073','R074','R075','R078','R079'," & Chr(13) & "" & Chr(10) & "'R080','R081','R083','R085','R086','R089','R100','R101','" _
, _
"R104','R105','R111','R112','R114','R117','R118','R119','R120','R121'," & Chr(13) & "" & Chr(10) & "'R122','R123','R124','R125','R126','R127','R128','R132','R140','R145','R146','R147','R148','R151','R152','R155','R156','R166'," & Chr(13) & "" & Chr(10) & "'" _
, _
"R167','R168','R169','R170','R171','R172','R174','R177','R178','R180','R181','R186','R187','R199','R208','R209','R238','R251'," & Chr(13) & "" & Chr(10) & "'R602','R675','R684','R700','R979','RB1','T013')" & Chr(13) & "" & Chr(10) & "AND area_tecnica IN ('T" _
, "X','FO') " & Chr(13) & "" & Chr(10) & "AND dt_foto ='"& zData &'")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Tabela_1"
.Refresh BackgroundQuery:=False
End With
O problema é com a variaval da data no final do WHERE..