Skip to content

Latest commit

 

History

History
50 lines (32 loc) · 1.32 KB

Excel.Parameter.SetParam.md

File metadata and controls

50 lines (32 loc) · 1.32 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Parameter.SetParam method (Excel)
vbaxl10.chm523079
vbaxl10.chm523079
Excel.Parameter.SetParam
af1f5b0a-75a1-ae85-b291-cc3ab514b0a3
05/03/2019
medium

Parameter.SetParam method (Excel)

Defines a parameter for the specified query table.

Syntax

expression.SetParam (Type, Value)

expression A variable that represents a Parameter object.

Parameters

Name Required/Optional Data type Description
Type Required XlParameterType One of the constants of XlParameterType, which specifies the parameter type.
Value Required Variant The value of the specified parameter, as shown in the description of the Type argument.

Example

This example changes the SQL statement for query table one. The clause (city=?) indicates that the query is a parameter query, and the example sets the value of city 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

[!includeSupport and feedback]