Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 1.57 KB

Excel.QueryTables.md

File metadata and controls

65 lines (43 loc) · 1.57 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
QueryTables object (Excel)
vbaxl10.chm520072
vbaxl10.chm520072
Excel.QueryTables
93511da3-598e-0aa3-fbc3-14bebff8838f
04/02/2019
medium

QueryTables object (Excel)

A collection of QueryTable objects.

Remarks

Each QueryTable object represents a worksheet table built from data returned from an external data source.

Example

Use the QueryTables property of the Worksheet object to return the QueryTables collection.

The following example displays the number of query tables on the active worksheet.

MsgBox ActiveSheet.QueryTables.Count

Use the Add method to create a new query table and add it to the QueryTables collection. The following example creates a new query table.

Dim qt As QueryTable 
sqlstring = "select 96Sales.totals from 96Sales where profit < 5" 
connstring = _ 
 "ODBC;DSN=96SalesData;UID=Rep21;PWD=NUyHwYQI;Database=96Sales" 
With ActiveSheet.QueryTables.Add(Connection:=connstring, _ 
 Destination:=Range("B1"), Sql:=sqlstring) 
 .Refresh 
End With

Methods

Properties

See also

[!includeSupport and feedback]