[英]I want to copy data in next rows in google sheet based upon certain cell value in a cell of the Preceding row
I have a large table in google spreadsheet.我在谷歌电子表格中有一张大桌子。 I want to find each row in that table that contains a specific keyword and insert fixed data rows after that row in the whole table.我想找到该表中包含特定关键字的每一行,并在整个表中的该行之后插入固定数据行。
function changingdatainnextrowbasedupondataincurrentrow() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Sheet0');
const vs = sh.getRange(2,1,sh.getLastRow() - 1, sh.getLastColumn()).getValues();
vs.forEach((r,i,a) => {
if(r[5] % 2 == 0) {
a[i + 1][6] += 1;//if column 6 in current row is even then add one to column seven in next row
}
});
sh.getRange(2,1,vs.length, vs[0].length).setValues(vs);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.