我确信我做错了什么,但我无法弄清楚是什么。下面的代码会影响我的所有工作表,而不仅仅是" Pipeline"我希望它影响的表格。
function onEdit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s1 = ss.getSheetByName("Pipeline");
var r = s1.getActiveCell();
if(r.getColumn() === 3, r.getValue()==='Closed' ) {
var nextCell = r.offset(0, 6);
var printPipeline = r.offset(0,1);
var digitalPipeline = r.offset(0,2);
var propelPipeline = r.offset(0,3);
printPipeline.clearContent(), digitalPipeline.clearContent(),propelPipeline.clearContent() ;
if( nextCell.getValue() === '')//checks for blank cell
nextCell.setValue(new Date())}
else if( r.getColumn() == 3, r.getValue()==='Lost' ) {
var nextCell = r.offset(0, 7);//offset (row,column)
var closedCell = r.offset(0, 6);
var pProductsCell = r.offset(0,8);
var pRevCell = r.offset(0,9);
var pLengthCell = r.offset (0,10);
var dProductsCell = r.offset(0,12);
var dRevCell = r.offset(0,13);
var dLengthCell = r.offset (0,14);
var prProductsCell = r.offset(0,16);
var prRevCell = r.offset(0,17);
var prLengthCell = r.offset (0,18);
closedCell.clearContent(), pProductsCell.clearContent(), pRevCell.clearContent(), pLengthCell.clearContent(), dProductsCell.clearContent(), dRevCell.clearContent(), dLengthCell.clearContent(), prProductsCell.clearContent(), prRevCell.clearContent(), prLengthCell.clearContent();
if( nextCell.getValue() === '')//checks for blank cell
nextCell.setValue(new Date())}}
答案 0 :(得分:0)
添加对工作表名称的检查,如果不等于“管道”,则返回:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var name=ss.getSheetName()
if(name!="Pipeline"){return}