Name
querytables.Add(Connection, Destination, [Sql])
Synopsis
Creates a new query table and adds it to the worksheet. Returns a QueryTable object.
|
Argument |
Description |
|---|---|
|
|
A string or object reference identifying the source of the data. |
|
|
A |
|
|
If the |
The Connection argument has different forms, depending on the type of data source being queried as described in the following table:
|
Data source |
Use to |
Sample connection argument |
|---|---|---|
|
Web page |
Perform a web query |
|
The Add method’s Connection argument uses the "URL;" prefix when performing a query on a web page. For example, the following code creates a new query table containing a real-time stock quote from Yahoo!:
Set ws = ThisWorkbook.Sheets("Other QueryTables")
strConn = "URL;http://finance.yahoo.com/q/ecn?s=dell"
Set qt = ws.QueryTables.Add(strConn, [QueryDestination])
qt.RefreshBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access