where do my SQL querries get stored in the MS query tool in excel?

G

Guest

I am not sure what happened but when I right click on my tables to edit my
querry I am getting a bunch of errors and I cannot open the MS query tool.

Where are my SQL queries stored? (please for the love of god tell me in the
spreadsheet somewhere)
 
S

SysMod

Look up the VBA Help for the QueryTable object and CommandText

Sub ListQTs()
Dim ws As Worksheet, qt As QueryTable
On Error Resume Next ' ignore errors getting SQL CommandText
For Each ws In ActiveWorkbook.Worksheets
For Each qt In ws.QueryTables
Debug.Print qt.Name, qt.Connection
Debug.Print vbTab, qt.CommandText
Next
Next
End Sub
 

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

Top