Macro: Set a cell formula with CSE (Ctrl+Shift+Enter)

Hi everyone,

I’m writing a macro in Calc to set a different formula for each cell in a specific range. I’m using setFormula to create each of them, but there is one that needs CSE (Control+Shift+Enter) to work.

My formula:

{=IFERROR(INDEX($A$10:$A$210;SMALL(IF(($H$10:$H$210=1);ROW($A$10:$A$1000)-ROW($A$9));ROW($A1));1);"-")}

I’ve looked in many places for an answer but I could only find something for VBA with FormulaArray.
Is it possible to do something similar in Basic?

My code for non array formula:

sMONTH=ThisComponent.Sheets.getByName("MES")
sMONTH.getCellByPosition(9,9).setFormula("=IFERROR(INDEX($A$10:$A$210;SMALL(IF(($H$10:$H$210=""NOVO"");ROW($A$10:$A$1000)-ROW($A$9));ROW($A1));1);""-"")")
	

Hallo

…setArrayFormula( your_formula_without_curlybraces_around )
1 Like

Thank you karolus!