Skip to content
Agent Tools

runFormula

Run one or more formulas without writing to any cell. Returns the calculated results. Useful for testing formulas or computing values without modifying the workbook.

Examples:

  • Single: { “formula”: “=SUM(A1:A10)” }
  • Batch: { “formulas”: [“=SUM(A1:A10)”, “=AVERAGE(B1:B10)”, “=COUNT(C1:C10)”] }
  • With temp values: { “formula”: “=A1*B1”, “apply”: [{ “cell”: “A1”, “value”: 5 }] }
  • Against a specific sheet: { “formula”: “=SUM(A:A)”, “sheet”: “Sheet2” }

Use “formulas” array to test multiple formulas in one call (more efficient than multiple calls).

Bare cell references (e.g. A1, SUM(A:A)) resolve against the primary workbook’s first sheet by default. Use the “sheet” parameter when you need them to resolve against a different sheet. The response includes a “_note” field identifying the sheet bare references resolved against, so you can verify they resolved where you intended.

Sheets in external (linked) workbooks can be read with workbook-qualified references inside the formula itself, e.g. =‘[external.xlsx]Sheet1’!A1. If an external sheet shares its name with a sheet in the primary workbook, the primary workbook’s sheet always wins for plain references — only the workbook-qualified form reaches the external one.

ParameterTypeDescription
applyobject[]optionalOptional temporary values to apply before running formula(s)
apply[].cellstringrequiredCell reference
apply[].valuestring | number | boolean | nullrequiredTemporary value to apply
formulastringoptionalSingle formula to evaluate (must start with ”=“)
formulasstring[]optionalArray of formulas to evaluate (more efficient for multiple formulas)
sheetstringoptionalSheet name against which bare cell references (e.g. A1, SUM(A:A)) resolve. Defaults to the primary workbook’s first sheet. Use this when you need formulas to evaluate in the context of a different sheet. Sheet names are matched across all workbooks in the model; on a name collision the primary workbook’s sheet wins, so external sheets with colliding names are only reachable via workbook-qualified references in the formula itself.