i find this code for remove duplicate row in google spraedsheet: from this url: https://developers.google.com/apps-script/articles/removing_duplicates
function removeDuplicates() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
var data = sheet.getDataRange().getValues();
var last=sheet.getLastRow();
var newData = new Array();
for(i in data){
//Logger.log(i);
var row = data[i];
//Logger.log(row[5]);
var duplicate = false;
for(j in newData){
//Logger.log(newData[j][5]);
if(row[5] == newData[j][5]){
duplicate = true;
}
}
if(!duplicate){
newData.push(row);
}
}
sheet.clearContents();
sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}
but this function start removing duplicate row from the first row, i want to start removing from the end row of sheet. How can i do this?
This code is going from Top to bottom i.e., from Row 1 to Row 2 and I guess, you want reverse of this i.e., Bottom to Top , last row to 1st row.
For this result, you can try this code snippet :
This code is untested. Let me know if this doesn't works or if you have any feedbacks/questions.
Thanks.
I believe that I reached here pretty late to save you from all the trouble, but just to make sure that people reaching this thread don't end up with the same frustration follow the guideline given here to solve the issue -
https://ladwhocodes.blogspot.com/2019/02/remove-duplicate-rows-from-your-google.html
Follow the comments given on the link to achieve what you want.
Try the JavaScript array
reverse()
method. It is used twice below:Please let me know if it works out.