Error: Err:508 problem while writing macro(setFormula) with libreoffice basic

Hi,

I have started to write a macro to organize my file as I want. I am going to finish it but I have locked a problem.

When I try to write a formula with setFormula, it gives that error Err:508

My Formula: oCellYD.setFormula("=IF((M" & i & "<>"""")," & "O" & i & ",0)")

It looks oCellYD.setFormula("=IF((M" & i & "<>")," & "O" & i & ",0)") as in libreoffice input line. So adding a " in the middle ‘<> "’ => ‘<> ""’ of formula by hand at input line it fixes.

And also when I Change my formula as oCellYD.setFormula("=IF((M" & i & "<>"")," & "O" & i & ",0)")

It gives #NAME? error. And If add a quotation mark as in Err:508, It fixes.

So my question, how can I fix this issue in macro.

The problem lies in your formula syntax. The correct syntax is =IF((M" & i & "<>"""");" & "O" & i & ";0)

When entering a formula directly into a cell, it is using the , because Options for Calc are stated so. However, when you move the formula into a cell from a macro, it need the correct separator - ;. That is why when adding a change directly to the cell works - it then accepts the , as the separator.

Thanks for your time. My issue is fixed. Thank you…

I have the same problem. I thought this was the answer, but it isn’t. When I use ;'s in the macro, it still shows up in the spreadsheet as ,'s in the value for the cell and displays as Err: 508. If I press Enter in the edit field, it then formats correctly (as a date in my case). F9 or Shift-Ctrl-F9 do not fix it. To look at the contents of the cell, there is no difference between before the Enter and after. Also, 508 is supposed to be unmatched parentheses.

My mistake. I missed one of the ,'s. So this is the solution. Thanks.