Ask Your Question
0

result of setFormula() not recognised (solved) [closed]

asked 2016-02-22 16:58:34 +0100

Pansmanser gravatar image

updated 2016-02-22 21:51:25 +0100

The following line of code inserts a formula using the function COUNTIF into cell F43.

 oSheet.getCellByPosition(5,42).setFormula("=COUNTIF(F33:F36,1)")

The formula is inserted in the cell exactly as expected, but the result in the spreadsheet is Err:508. (I tried ""=1"", but the result is the same.) I can manually copy and paste the formula from the formula bar back in to the formula bar and it then works correctly. A similar expression using a SUM function in place of COUNTIF works correctly. Is there some limitation on which functions can be used in setFormula? Or am I missing something?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-08-30 12:42:50.634067

Comments

When the sheet is copied from elsewhere, Calc seems to be deciding that the column F is all DATES. This may have something to do with problem, but does not entirely explain it. The problem reproduces in another column. Now there is a second less important question: why is Col F becoming DATES?

Pansmanser gravatar imagePansmanser ( 2016-02-22 17:15:41 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2016-02-22 18:02:18 +0100

pierre-yves samyn gravatar image

updated 2016-02-22 18:03:27 +0100

Hi

You have to use same separator as ToolsOptionsCalcFormulaSeparatorsFunction.

For example, with my french UI :

oSheet.getCellByPosition(5,42).setFormula("=COUNTIF(F33:F36;1)")

So, is it , for you?

Regards

edit flag offensive delete link more

Comments

Thank you so much, Pierre-Yves, the semi-colon has fixed it, although, yes, the separator IS defined as comma, so there is a bit of mystery there! Strange also that you can get away with a comma separator when entering the formula manually. (I've fixed the date problem)

Pansmanser gravatar imagePansmanser ( 2016-02-22 21:50:42 +0100 )edit

Question Tools

1 follower

Stats

Asked: 2016-02-22 16:58:34 +0100

Seen: 636 times

Last updated: Feb 22 '16