ooptennoort
Board Regular
- Joined
- Mar 29, 2021
- Messages
- 67
- Office Version
- 365
- Platform
- Windows
I have this generic VBA code that allows me to load a query to a worksheet (by default I don't load queries to save time etc.) but it only works if I fill in the query name.
But I want to be able to simply select the query and then run my macro (which will then fill in selected query's name).
Anyone?
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=" & query.Name _
, Destination:=Range("$A$1")).QueryTable
I am sort of looking for the macro equivalent of Active.Query or selected.query (which I don't believe exist)... workaround???
But I want to be able to simply select the query and then run my macro (which will then fill in selected query's name).
Anyone?
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=" & query.Name _
, Destination:=Range("$A$1")).QueryTable
I am sort of looking for the macro equivalent of Active.Query or selected.query (which I don't believe exist)... workaround???