admin管理员组文章数量:1389779
I have a table which cells have functions/formulas, like this one:
I need a script that create a new row copying to it the functions/formulas of the last used row. I find this script which create a new row but it doesn't copy functions/formulas. How could I implement this formatting copy task in Google Script without having to manually select and copy?
Thanks for any help!
I have a table which cells have functions/formulas, like this one:
I need a script that create a new row copying to it the functions/formulas of the last used row. I find this script which create a new row but it doesn't copy functions/formulas. How could I implement this formatting copy task in Google Script without having to manually select and copy?
Thanks for any help!
Share Improve this question edited May 23, 2017 at 12:31 CommunityBot 11 silver badge asked Jul 26, 2013 at 21:32 craftApprenticecraftApprentice 2,77721 gold badges61 silver badges87 bronze badges2 Answers
Reset to default 3You can copy formulas just as easily you copy values, just use Range.getFormula()
and Range.setFormula()
instead of .getValue()
and .setValue()
. See documentation on spreadsheet service.
Inserting a row below the last one is pretty basic, use insertRowAfter and getLastRow in a simple script.
EDIT : in case you don't find it, here is an example of another simple way to do it, copying everything in one step
function duplicateLastRow(){
var ss = SpreadsheetApp.getActiveSheet();
ss.insertRowAfter(ss.getLastRow());
ss.getRange(ss.getLastRow(),1,1,ss.getLastColumn()).copyTo(ss.getRange(ss.getLastRow()+1,1));
}
Method Sheet.appendRow allow append row in one mand as atomic action.
版权声明:本文标题:javascript - Google Script: function that insert new row copying functionsformulas from last row - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744622070a2616086.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论