title | keywords | f1_keywords | ms.assetid | ms.date | ms.localizationpriority | |
---|---|---|---|---|---|---|
Queries.Add method (Excel) |
vbaxl10.chm976074 |
|
184711c0-2ce4-ba6e-df56-1f7fdd60ab2c |
05/09/2019 |
medium |
Adds a new WorkbookQuery object to the Queries collection.
expression.Add (Name, Formula, Description)
expression A variable that represents a Queries object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
Name | Required | String | The name of the query. |
Formula | Required | String | The Power Query M formula for the new query. |
Description | Optional | Variant | The description of the query. |
WorkbookQuery
The following example shows how to add a query to a workbook from an existing CSV file.
Dim myConnection As WorkbookConnection
Dim mFormula As String
mFormula = _
"let Source = Csv.Document(File.Contents(""C:\data.txt""),null,""#(tab)"",null,1252) in Source"
query1 = ActiveWorkbook.Queries.Add("query1", mFormula)
[!includeSupport and feedback]