尝试获取它以使它通过I列,如果I列不等于0,J列不等于”,则它将信息复制到B,C,G,H和I列中,并将其放在另一张纸上。
我的代码看起来正确,但是我认为var outrng存在一个问题,我似乎无法弄清。
任何人都可以看到问题吗?
function createOrder()
{
var s = SpreadsheetApp.getActiveSpreadsheet();
var sht = s.getSheetByName('Products')
var drng = sht.getDataRange();
var rng = sht.getRange(2,1, drng.getLastRow()-1,drng.getLastColumn());
var rngA = rng.getValues();//Array of input values
var rngB = [];//Array where values that past the condition will go
var b = 0;//Output iterator
for(var i = 0; i < rngA.length; i++)
{
if(rngA[i][8] != '0' && rngA[i][9] != '')
{
rngB[b]=[];//Initial new array
rngB[b].push(rngA[i][1],rngA[i][2],rngA[i][6],rngA[i][7],rngA[i][8]);
b++;
}
}
var shtout = s.getSheetByName('Order Sheet');
var outrng = shtout.getRange(2,1,rngB.length,2);//Make the output range the same size as the output array
outrng.setValues(rngB);
};