I have written a formula in the macro for spreadsheet to calculate as below . This works fine when i paste it in the cell but returns zero when I put it in the macro. Can anybody please explain what is going wrong?
oSheetKeys.getCellByPosition(10,i+2) ="=countif($C$3:C3;C3)"
[Solved] Countif written in macro returns zero value
[Solved] Countif written in macro returns zero value
Last edited by Hagar Delest on Thu Nov 01, 2018 5:50 pm, edited 1 time in total.
Reason: tagged solved
Reason: tagged solved
OpenOffice 3.1
Re: countif written in macro returns zero value
Welcome to the forums.
While I admit that my knowledge of macros is almost nil, I have to wonder about the fact that you have the countif formula inside quotation marks.
Have you tried oSheetKeys.getCellByPosition(10,i+2) = countif($C$3:C3;C3)
While I admit that my knowledge of macros is almost nil, I have to wonder about the fact that you have the countif formula inside quotation marks.
Have you tried oSheetKeys.getCellByPosition(10,i+2) = countif($C$3:C3;C3)
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
Re: countif written in macro returns zero value
The object returned by
refers to the whole cell, all of its properties and methods. If you want to set the Formula of the cell, do this
Judging from the i in your code, you are doing this in a loop. The result will be to set every cell to have the exact same formula. Is that what you want?
Code: Select all
oSheetKeys.getCellByPosition(10,i+2)
Code: Select all
oSheetKeys.getCellByPosition(10,i+2).Formula ="=countif($C$3:C3;C3)"
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: countif written in macro returns zero value
Thanks FJCC. oSheetKeys.getCellByPosition(10,i+2).Formula ="=countif($C$3:C3;C3)" This worked. I was putting. value instead of Formula.
OpenOffice 3.1
Re: countif written in macro returns zero value
Yes..its a loop I need to have the formula incremented except $C$3. I have used this. oSheetKeys.getCellByPosition(10,i+2).Formula ="=countif(Keys.$C$2" + ":Keys.C" + (i+2) + ";Keys.C" + (i+2+1) + ")". Although it works if you have an easier way and simpler please do suggest. I am new to macros
OpenOffice 3.1