Inserting a new row in spreadsheet
I have this script:
function开发者_运维问答 onEdit(e) {
var sheet = e.source.getActiveSheet();
var range = e.source.getActiveRange();
// 3 is column C
if (range.getColumn() == 3) {
if (range.getValue() != "") {
sheet.insertRowAfter(range.getRow());
}
}
}
When the script inserts a row, I would like it to type " " (a space) in column 8 (h) of the new line. How do I go about doing this?
function onEdit(e) {
var sheet = e.source.getActiveSheet();
var range = e.source.getActiveRange();
// 3 is column C
if (range.getColumn() == 3) {
if (range.getValue() !== " ") {
sheet.insertRowAfter(range.getRow());
}
}
}
Certainly, replace your actual code with this.
How about this:
if (range.getvalue() != "") {
sheet.insertRowAfter(range.getRow());
var newRange = e.source.getCell(4, 8);
newRange.setValue(' ');
}
精彩评论