JoeVBAHelp
New Member
- Joined
- Aug 25, 2016
- Messages
- 14
Hi all
I am trying to write some VBA code to delete all Power query connections & Sources from my workbook.
So far I have the code below, this does delete the connections but when I open the 'Show Queries' list all of my queries are still there.
FYI I dont want to delete the actual tables, just the links to the power query so I can send to somebody else and they just get the data.
Workbook has 23 separate queries and need to send every week, would save me a lot of time with some VBA code
Thanks for you help!
I am trying to write some VBA code to delete all Power query connections & Sources from my workbook.
So far I have the code below, this does delete the connections but when I open the 'Show Queries' list all of my queries are still there.
FYI I dont want to delete the actual tables, just the links to the power query so I can send to somebody else and they just get the data.
Workbook has 23 separate queries and need to send every week, would save me a lot of time with some VBA code
Thanks for you help!
Code:
Sub DeleteAllPQ()
Dim cn As Object
Dim ws As Worksheet
Dim qryT As QueryTable
For Each cn In ActiveWorkbook.Connections
cn.Delete
Next cn
For Each ws In ActiveWorkbook.Worksheets
For Each qryT In ws.QueryTables
qryT.Delete
Next qryT
Next ws
End Sub