简体   繁体   中英

Insert new row and move data based on cell text

Trying to automate a Google sheet to save time for a team member. I have zero scripting experience. I am trying to insert a row based on a "Yes" result from column K in a Google form submission sheet and then move data in cells L:P to the new row, all without messing up the query functions that are pulling this data.

Is this possible?

Appending selected data from a form submission

function onFormSubmit(e) {
  var ss=SpreadsheetApp.openById('SpreadsheetID');
  var sh=ss.getSheetByName('Sheet Name')
  if(e.values[11]=="Yes") {
    var nV=e.values.slice(11,16);
    ss.appendRow(nV);
  }
}

Since you said that you have zero scripting experience, I should warn you that you cannot run this function without supplying the event object and personally I would never append new rows to a linked sheet. I would append the rows to another sheet instead. There have been problems with the onFormSubmit trigger lately which causes spurious additional triggers as described here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM