Javascript 如何基于另一个单元格中的值替换一个单元格中的值?
我如何将其添加到上述脚本中?该操作需要在将数据复制到工作表中后执行。我只是一个VB程序员。”“学生AM A”是一张不含公式的表格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
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
进一步阅读:
For each cell in ‘Students AM A'!N7:N77 then
If Ncell= ‘Menu!D14' then Hcell = ”O"
Check next cell
End