Add Method (QueryTables Collection)

         Example         Applies To

Creates a new query table. Returns a QueryTable object that represents the new query table.

Syntax

expression.Add(Connection, Destination, Sql)

expression   Required. An expression that returns a QueryTables object.

Connection   Required Variant. The data source for the query table. Can be one of the following:

Destination   Required Range. The cell in the upper-left corner of the query table destination range (the range where the resulting query table will be placed). The destination range must be on the worksheet that contains the QueryTables object specified by expression.

Sql   Optional Variant. The SQL query string to be run on the ODBC data source. This argument is optional when you’re using an ODBC data source (if you don’t specify it here, you should set it by using the Sql property of the query table before the table is refreshed). You cannot use this argument when a QueryTable object, text file, or ADO or DAO Recordset object is specified as the data source.

Remarks

A query created by this method isn’t run until the Refresh method is called.