Queries.Add Method (Excel)

Adds a new WorkbookQuery object to the Queries collection.


expression. Add( Name, Formula, Description)

expression A variable that represents a 'Queries' object.


| 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



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)

See also

Queries Object