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.Refresh
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.