Skip to content

Latest commit

 

History

History
53 lines (32 loc) · 1.2 KB

Excel.queries.add.md

File metadata and controls

53 lines (32 loc) · 1.2 KB
title keywords f1_keywords ms.assetid ms.date ms.localizationpriority
Queries.Add method (Excel)
vbaxl10.chm976074
vbaxl10.chm976074
184711c0-2ce4-ba6e-df56-1f7fdd60ab2c
05/09/2019
medium

Queries.Add method (Excel)

Adds a new WorkbookQuery object to the Queries collection.

Syntax

expression.Add (Name, Formula, Description)

expression A variable that represents a Queries object.

Parameters

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.

Return value

WorkbookQuery

Example

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]