开发者

Inserting a new row in spreadsheet

开发者 https://www.devze.com 2023-01-25 21:30 出处:网络
I have this script: function开发者_运维问答 onEdit(e) { var sheet = e.source.getActiveSheet(); var range = e.source.getActiveRange();

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(' ');
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号