VB way to remove the query from a Query Table?

  • Thread starter Thread starter Toby Erkson
  • Start date Start date
T

Toby Erkson

I have a workbook that uses a Query Table. When they click on a button the
workbook is saved, minus various commandbuttons, their VB code, and the
Workbook_Open code (thank you Chip Pearson website!). I also want to make
sure that the Query Table now becomes static, that it does NOT update.

I tried using the macro recorder to capture the code necessary to remove the
Query Table property of the dataset but that was a bust. I do have the
following code that successfully keeps the Query Table from updating itself in
the static workbook:
Sheets("sheetname").QueryTables("querytablename").EnableRefresh = False

Is there a VB way to basically clear the "Save query definition" checkbox in
the "External Data Range Properties" window of a Query Table?

Thanks
 
cells.copy
Cells.PasteSpecial paste:=xlValues

will remove the query table as leave the data.

If you have other formulas on the sheet you don't want to lose, then just do
the area of the query table

With Activesheet.querytables(1).ResultRange
.copy
.pasteSpecial paste:=xlValues
End With
 
Thanks Tom. I was thinking of the copy/paste method as well but I wa
hoping for a cleaner way (a method or property). I'll use what yo
suggested :-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top