Google apps script 基于列中的单元格分配值
我编写了以下脚本,以基于另一列中的值在列中插入某些值Google apps script 基于列中的单元格分配值,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我编写了以下脚本,以基于另一列中的值在列中插入某些值 for(i=1;i
for(i=1;i }
嗯,我本来希望有更多的函数,所以我不得不猜测一下,但我建议尝试一下这样的功能:
function myfunction() {
const ss=SpreadsheetApp.getActive();
const sh=ss.getActiveSheet();//I dont know this at all
const vA=sh.getDataRange().getValues();//Im guessing on this
let oA=sh.getRange(1,24,sh.getLastRow(),1).getValues();//which leads to this
for (i = 1; i < sh.getLastRow(); i++) {
if (vA[i][21]=="SP") {oA[i][0]='01'}
else if (vA[i][21]=="MCD") {oA[i][0]='02'}
else if (vA[i][21]=="MCR") {oA[i][0]='03'}
else {oA[i][0]='99'};
}
sh.getRange(1,24,oA.length,oA[0].length).setValues(oA);
函数myfunction(){
const ss=SpreadsheetApp.getActive();
const sh=ss.getActiveSheet();//我一点也不知道
const vA=sh.getDataRange().getValues();//我在猜这个
让oA=sh.getRange(1,24,sh.getLastRow(),1).getValues();//这会导致
对于(i=1;i
如果发生任何其他情况,我无法确定能否请您提供有关如何检索
vA
的代码?这就是关键。一次性使用设置值比每次使用设置值更有意义。非常感谢。