Ask LibreOffice - RSS feedhttps://ask.libreoffice.org/en/questions/Questions and answers for LibreOfficeenFri, 02 Nov 2012 23:13:48 +0100macro overlays formula in cellhttps://ask.libreoffice.org/en/question/7347/macro-overlays-formula-in-cell/When a cell is selected and it contains a formula, Calc by default shows the formula in the formula bar and the calculation result in the cell.
But when I code <I>=MyMacro()</I> in a cell and MyMacro() saves a result in the cell with <I>thisComponent.currentController.selection.setValue(result)</I> the formula is overwritten with the result and the call to MyMacro() is lost. The result displays in both the selected cell and in the formula bar.
What did I do wrong or fail to do?Thu, 01 Nov 2012 02:07:34 +0100https://ask.libreoffice.org/en/question/7347/macro-overlays-formula-in-cell/Answer by m.a.riosv for <p>When a cell is selected and it contains a formula, Calc by default shows the formula in the formula bar and the calculation result in the cell.</p>
<p>But when I code <i>=MyMacro()</i> in a cell and MyMacro() saves a result in the cell with <i>thisComponent.currentController.selection.setValue(result)</i> the formula is overwritten with the result and the call to MyMacro() is lost. The result displays in both the selected cell and in the formula bar. </p>
<p>What did I do wrong or fail to do?</p>
https://ask.libreoffice.org/en/question/7347/macro-overlays-formula-in-cell/?answer=7350#post-id-7350I think, maybe you do not need to save the result in the cell, if the macro function MyMacro() return a value, that's all, like any other function.
Function sample in LibreOffice help:
Function VOL(a, b, c)
VOL = a*b*c
End FunctionThu, 01 Nov 2012 04:53:26 +0100https://ask.libreoffice.org/en/question/7347/macro-overlays-formula-in-cell/?answer=7350#post-id-7350Comment by Ron for <p>I think, maybe you do not need to save the result in the cell, if the macro function MyMacro() return a value, that's all, like any other function.</p>
<p>Function sample in LibreOffice help:</p>
<p>Function VOL(a, b, c)</p>
<p>VOL = a<em>b</em>c</p>
<p>End Function</p>
https://ask.libreoffice.org/en/question/7347/macro-overlays-formula-in-cell/?comment=7433#post-id-7433SOLVED - thank youFri, 02 Nov 2012 23:13:48 +0100https://ask.libreoffice.org/en/question/7347/macro-overlays-formula-in-cell/?comment=7433#post-id-7433