Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.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
Javascript 如何基于另一个单元格中的值替换一个单元格中的值?_Javascript_Google Apps Script_Google Sheets - Fatal编程技术网

Javascript 如何基于另一个单元格中的值替换一个单元格中的值?

Javascript 如何基于另一个单元格中的值替换一个单元格中的值?,javascript,google-apps-script,google-sheets,Javascript,Google Apps Script,Google Sheets,我如何将其添加到上述脚本中?该操作需要在将数据复制到工作表中后执行。我只是一个VB程序员。”“学生AM A”是一张不含公式的表格 function CopyinData_AM_A() { /* Edit the vars below this line for your needs */ var sourceSheet = "Students AM" ; // Enter the name of the sheet with the source data var sou

我如何将其添加到上述脚本中?该操作需要在将数据复制到工作表中后执行。我只是一个VB程序员。”“学生AM A”是一张不含公式的表格

function CopyinData_AM_A() {
/* Edit the vars below this line for your needs */
var sourceSheet  = "Students AM" ;  // Enter the name of the sheet with the source data
var sourceRange = "B7:N77" ; // Enter the range of the cells with the source data
var targetSheet = "Students AM A" ; // Enter the name of the target sheet
var targetRange = "B7:N77" ; // Enter the range of cells you wish to copy data to. Note this must be same size as source range.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sourceSheet);
var values = sheet.getRange(sourceRange).getValues();
ss.getSheetByName(targetSheet).getRange(targetRange).setValues(values);
}
我在VB中这样做没有任何问题,我大约3个月前才开始使用google脚本。有人推荐一本好书来帮助我学习这个谷歌脚本吗?

一旦你有了一个值范围,你就可以在行中循环并将值与参考值进行比较 您可以使用例如a、条件和
=

要与函数的其余部分合并的示例:

var ss=SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet=ss.getSheetByName(“学生AM”);
var referenceSheet=ss.getSheetByName(“菜单”);
var referenceValue=referenceSheet.getRange(“D14”).getValue();
var sourceRange=“B7:N77”;
var values=sourceSheet.getRange(sourceRange.getValues();
对于(变量i=0;i
进一步阅读:


欢迎来到Stackoverflow,大卫!一个要记住的指针,如果你的文章能切中要害,可能会更有帮助。像书籍和教程推荐这样的问题在这里可能不合适,因为我们的目标仅仅是提供编码帮助。这些可能更适合论坛。我之所以这样说,是因为如果某个问题被标记为偏离主题或不清楚,你可能会面临结束该问题的风险。一定要记住这一点。
      For each cell in ‘Students AM A'!N7:N77 then
              If Ncell= ‘Menu!D14' then Hcell = ”O"
              Check next cell
      End