You can use vba to pass the query to the command text,
Use a helper sheet with your query listed line by line
=" line 1 of query"
=" line 2 etc. "
=" line 3&E4&"rest of line etc. "
E4 would be a cell ref to make the query dynamic from Excel
then concatenate these lines into one cell,
use vba similiar to the below, my range "SQLCOUNTRY" is the cell of concatenated query
With ActiveWorkbook.Connections("EUUKSQL01 dashboard StockSalesAggregateWeek2") _
.OLEDBConnection
.CommandText = Sheets("CountryScript").Range("SQLCOUNTRY").Value
End With
This way any part of the query can be driven off an existing excel Cell
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…