Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 谷歌电子表格在用户编辑时将一个值替换为另一个值_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 谷歌电子表格在用户编辑时将一个值替换为另一个值

Google apps script 谷歌电子表格在用户编辑时将一个值替换为另一个值,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我刚刚开始了解谷歌电子表格脚本,但我不知道如何做到这一点: 我正在寻找一个脚本,它可以在编辑/添加时将一个特定的单元格内容值冰淇淋替换为另一个值甜甜圈 到目前为止,我在Stackoverflow上找到了这段脚本,但它只对单元格有效,而不是单元格中的值,如icecream 它只对我起作用,我希望它能自动执行,每次用户在框中输入特定值时。因此,如果用户将冰淇淋输入单元格,则需要自动将其替换为甜甜圈。不管值icecream在哪个单元格中,只要在整个文档中将单词icecream自动更改为donut,每次

我刚刚开始了解谷歌电子表格脚本,但我不知道如何做到这一点:

我正在寻找一个脚本,它可以在编辑/添加时将一个特定的单元格内容值冰淇淋替换为另一个值甜甜圈

到目前为止,我在Stackoverflow上找到了这段脚本,但它只对单元格有效,而不是单元格中的值,如icecream

它只对我起作用,我希望它能自动执行,每次用户在框中输入特定值时。因此,如果用户将冰淇淋输入单元格,则需要自动将其替换为甜甜圈。不管值icecream在哪个单元格中,只要在整个文档中将单词icecream自动更改为donut,每次有人键入单词icecream

有人能帮我吗

function doTest() {
SpreadsheetApp.getActiveSheet().getRange('E3').setValue('donut');
}

这对我有用。让我知道它是否适合你

function onEdit(event) {

  var ss = SpreadsheetApp.getActiveSpreadsheet();  
  var sheet = ss.getSheets()[0];
  var active = sheet.getActiveCell();
  var cell = active.getValue();


  //if cell's value is equal to icecream then set the active's value to donut
  if(cell === "icecream"){
  active.setValue("donut");    

  };
};

好的,所以我让它在编辑时自动工作:函数OneDiteEvent{SpreadsheetApp.getActiveSheet.getRange'E3'.setValue'donut';}但我仍然不知道如何应用于整个表单和冰淇淋。。。任何帮助都将不胜感激!找到了如何应用于整个工作表的方法:function onEditevent{SpreadsheetApp.getActiveSheet.getRange'A:G'.setValue'Hello';}仍然没有找到冰淇淋并用甜甜圈替换它。。。