Skip to content

Latest commit

 

History

History
64 lines (43 loc) · 2.02 KB

Excel.Parameters.md

File metadata and controls

64 lines (43 loc) · 2.02 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Parameters object (Excel)
vbaxl10.chm524072
vbaxl10.chm524072
Excel.Parameters
d67147f1-d587-a9e4-ed8e-8a1140e8a868
03/30/2019
medium

Parameters object (Excel)

A collection of Parameter objects for the specified query table.

Remarks

Each Parameter object represents a single query parameter. Every query table contains a Parameters collection, but the collection is empty unless the query table is using a parameter query.

You cannot use the Add method on a URL connection query table. For URL connection query tables, Microsoft Excel creates the parameters based on the Connection and PostText properties.

Example

Use the Parameters property of the QueryTable object to return the Parameters collection.

The following example displays the number of parameters in query table one.

MsgBox Workbooks(1).ActiveSheet.QueryTables(1).Parameters.Count

Use the Add method to create a new parameter for a query table. The following example changes the SQL statement for query table one. The clause "(city=?)" indicates that the query is a parameter query, and the value of city is set to the constant Oakland.

Set qt = Sheets("sheet1").QueryTables(1) 
qt.Sql = "SELECT * FROM authors WHERE (city=?)" 
Set param1 = qt.Parameters.Add("City Parameter", _ 
 xlParamTypeVarChar) 
param1.SetParam xlConstant, "Oakland" 
qt.Refresh

Methods

Properties

See also

[!includeSupport and feedback]