When I run the following function in my sheet:
function removeDuplicateRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var column = sheet.getRange('D580:D');
var data= column.getValues();
var newData = new Array();
for(i in data){
var row = data[i];
var duplicate = false;
for(j in newData){
if(row.join() == newData[j].join()){
duplicate = true;
}
}
if(!duplicate){
newData.push(row);
}
}
sheet.clearContents();
sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}
Nothing happens, it just times out. It seems to be due to my 'column' variable when I identify the range. If I leave it blank it runs but I don't want it to hit the first 580 rows. Anybody out there know why this happens?
Thanks for any help,
foris bad. Especially when you are missing short-circuit logic steps, like stopping the inner loop once you know you have a duplicate. But, there's much better methods than storing things in an array and traversing that array every time. See some of my answers about duplicate detection.Sheet#deleteRow