用于从“活动”列表中删除名称的Google脚本无效

时间:2018-04-24 18:46:13

标签: javascript google-apps-script google-sheets

我正在尝试为我的女生联谊会名单写一个剧本,但我无法让它发挥作用。

我希望能够输入女孩的状态并让脚本将她的姓名从Actives列表中移除到她要求的任何名称,除非她正在毕业或转学,然后我只需要将她的名字复制到该名称上页面的页面。这就是我所拥有的:

function onEdit() {
  // assumes source data in sheet named Actives (not pending termination / resignation)
  // target sheet of move to named Other (non-active), Resignation Pending, or Termination Pending
  // test column with status is col 4 or D
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
  var s = SpreadsheetApp.getActive();
  var r = SpreadsheetApp.getActiveRange()
  if (s.getName() == "Actives (not pending termination/resignation)" &&
    r.getColumn() == d && r.getValue() == "resigned") {
    var row = r.getRow();
    var numColumns = s.getLastColumn();
    var targetSheet = sheet.getSheetByName() == "Resignation Pending";
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).moveTo(target);
    s.deleteRow(row);
  }
  if (s.getName() == "Actives (not pending termination/resignation)" &&
    r.getColumn() == 4 && r.getValue() == "transferred") {
    var row = r.getRow();
    var numColumns = s.getColumn(i);
    var targetSheet = sheet.getSheetByName() == "Other (non-active)";
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).moveTo(target);
    s.deleteRow(row);
  }
  if (s.getName() == "Actives (not pending termination/resignation)" &&
    r.getColumn() == 4 && r.getValue() == "offcampus") {
    var row = r.getRow();
    var numColumns = s.getColumn(e);
    var targetSheet = sheet.getSheetByName() == "Other (non-active)";
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).moveTo(target);
    s.deleteRow(row);
  }
  if (s.getName() == "Actives (not pending termination/resignation)" &&
    r.getColumn() == 4 && r.getValue() == "inactive") {
    var row = r.getRow();
    var numColumns = s.getColumn(a);
    var targetSheet = sheet.getSheetByName() == "Other (non-active)";
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).moveTo(target);
    s.deleteRow(row);
  }
  if (s.getName() == "Actives (not pending termination/resignation)" &&
    r.getColumn() == 4 && r.getValue() == "term") {
    var row = r.getRow();
    var numColumns = s.getLastColumn();
    var targetSheet = sheet.getSheetByName() == "Termination pending";
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).moveTo(target);
    s.deleteRow(row);
  }
  if (s.getName() == "Actives (not pending termination/resignation)" &&
    r.getColumn() == 4 && r.getValue() == "grad4") {
    var row = r.getRow();
    var numColumns = s.getLastColumn();
    var targetSheet = sheet.getSheetByName() == "Gradutating Seniors";
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).copyTo(target);
  }
  if (s.getName() == "Actives (not pending termination/resignation)" &&
    r.getColumn() == 4 && r.getValue() == "grad5") {
    var row = r.getRow();
    var numColumns = s.getLastColumn();
    var targetSheet = sheet.getSheetByName() == "Fifth Year Seniors";
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).copyTo(target);
  }
}

0 个答案:

没有答案