excelvbapowerquery

How to Change Excel Power Query Paramaters with VBA


How to change Excel PowerQuery Paramaters with VBA?

i.e. These Paramaters:

Excel Power Query

Right now the Paramater has a value of 8, and is used in refreshing all other power queries. How can I change this paramater with VBA?

The Macro recorder does not show anything.


Solution

  • Thanks to QHarr, I figured it out. Simply edit the Power Query M Code - the Parameter value is first item in the Code.

    e.g.

    5 meta [IsParameterQuery=true, Type="Number", IsParameterQueryRequired=true]
    

    5 is the Parameter Value.

    To edit, use the "Formula" Property e.g.

    ThisWorkbook.Queries("ParameterName").Formula = 'New code here