I am receiving the length error when running this script, but if I comment out the condition and pull everything there is no issue. Error in line "sp.getRange(1,1,data.length,data[0].length).setValues(data); "
I have triple-checked that column 22 is the column I want (column V) and the criteria "Denver" exist in that column but nothing is being returned to data.
Any explanation would be appreciated.
function Packaging() {
var t = SpreadsheetApp.openById('1kNq2irlV39yDRtuJPrkb3-572guw4wn9UsR2t5_I0pR');
//Grab PACKAGING COST
var pp = t.getSheetByName('RawData');
var ppk = pp.getRange(1,1,pp.getLastRow(),pp.getLastColumn()).getValues();
var data = []
for (var i = 0; i< ppk.length ; i++){
if(ppk[i][22] == "Denver")
{
data.push(ppk[i])
}
}
//Write in current sheet
var s = SpreadsheetApp.getActiveSpreadsheet();
//Write Packaging
var sp = s.getSheetByName('PackagingCost2');
sp.getRange(1,1,sp.getLastRow(),sp.getLastColumn()).clearContent();
sp.getRange(1,1,data.length,data[0].length).setValues(data);
//sp.getRange(1,1,ppk.length,ppk[0].length).setValues(ppk);
}