Macro Displays Err

I’ve got a spreadsheet with a button that, among other things, populates the formula of a specific cell. However, the result always initially shows as “Err:508”. If I think click on the formula wizard button and simply close it without changing anything, the formula calculates and displays properly. Any idea of what this is happening?

Example.ods

If formula not change… Why you set every execute?

It was just a simple example to recreate the error. The actual spreadsheet I’m working on has a lot more going on and the formula does change depending on various field values.

Update (earlier assumption about separator setting was wrong):

The formula string in the macro uses the , comma function parameter separator. Instead, use the ; semicolon separator. Reason is that setting the formula string uses the API formula grammar, which if instead comma is used leads to Err:508 here. Editing the formula in the UI then if the comma matches the UI function separator makes it compile.

Putting the formula on each execution of the macro is indeed unnecessary.

@erAck: hit me by one minute … ‘;’ instead of ‘,’ works here …

Thanks for the detailed explanation.

It’s estrange, I set separator argument in function a “,”, but in your code work with “;”

cell = workSheet.getCellRangeByName("LUKBase")
cell.Formula = "=LOOKUP(SUM(RollInOrderRange); CharTotal; LuckScore)"

Yep, switching to semi-colons fixed the issue. Thanks.