[英]On edit of a row in google sheet execute a formula on the data of set row and paste the result of the formula in the first column of set row
I am making a database of items .我正在制作一个项目数据库。 As items will be edited by many people I would like formulas to be hidden so people would not manipulate them easily compromising the database.
由于项目将被许多人编辑,我希望隐藏公式,这样人们就不会轻易地操纵它们而损害数据库。
I tried to edit a script that recognizes any edit within a row and execute a formula on column values of set row pasting the result of the formula in column A of set row.我试图编辑一个脚本,该脚本识别行内的任何编辑,并在设置行的列值上执行一个公式,将公式的结果粘贴到设置行的 A 列中。
As I am very new to google app script I don't know how to proceed and many examples I have looked through don't do what I want.由于我对谷歌应用脚本非常陌生,我不知道如何继续,而且我浏览过的许多示例都没有达到我想要的效果。
I hope what I have written is clear.我希望我写的很清楚。
Thanks in advance for any help!提前感谢您的帮助!
Here is the code I wrote:这是我写的代码:
function onEdit(e) {
// Your sheet params
var sheetName = "Sheet1";
var ModifiedColumnIndex = 1;
var ModifiedColumnLetter = 'A';
var range = e.range; // range just edited
var sheet = range.getSheet();
if (sheet.getName() !== sheetName) {
return;
}
// If the column isn't our source column
if (range.getColumn() != ModifiedColumnIndex) {
var row = range.getRow();
// Formula to be executed on the edited rows cells
var formula = sheet + row [lower[trim(B&" "&C&" "&D&" "&E&" "&F&" "&G&" ["&I&"]"]])
var ModifiedRange = sheet.getRange(ModifiedColumnLetter + row.toString());
//Inserting formula into column A
ModifiedRange.setValue(formula);
};
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.