Hello,
I'm using th efollowing to add a query to an excel worksheet:
This works, however if I change to another sheet I get a run time error # 5.....
How can I modify the above so I can insert different query tables to different sheets in workbook?
I'm using th efollowing to add a query to an excel worksheet:
Code:
With ActiveSheet.QueryTables.Add(Connection:=sConn, Destination:=Range("A1"))
.CommandText = sSql
.Refresh BackgroundQuery:=False
End With
This works, however if I change to another sheet I get a run time error # 5.....
How can I modify the above so I can insert different query tables to different sheets in workbook?