Insert and run a query formula

To create a macro add this method into your macro along with the query.

This macro inserts and runs a query formula to a target cell:

Sub InsertAndExecuteQueryFormulaToCell ()
QAAMacro.InsertAndExecuteQueryFormulaToCell "H13","=QAA_SR(""1,2,ss5,LA,F='PK1,K=DbC,F=A,K=/LA/Ldg,F=10000,T=13000,K=/LA/AccCde,F=2005/009,T=2005/009,K=/LA/Prd,E=0,O=/LA/Ldg,E=0,O=/LA/AccCde,E=0,O=/LA/Prd,RT=4154,RF=111111011,AF=1,TP=,"",)"
End Sub

To insert the query to sheets other than the active sheet, change the cell reference from H13 to SheetName!H13.

Ensure that two double quotes are used after the function name, for example: "=QAA_SR(""..., and at the end of the formula: "",)".

This macro supports all query formulas:

  • QAA_RL: Reference Link
  • QAA_SL: Summary Link
  • QAA_SR: Summary Report
  • QAA_DR: Detail Report.