Reputation: 73
I am fairly new to scripts.
I found the following script and would like it to be able to search in Column W for any duplicates and when it finds any to then delete the duplicated rows
function removeDuplicates() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getLastRow();
var firstColumn = sheet.getRange(2, 2, rows, 1).getValues();
for (var i = rows; i >= 2; i--) {
if (firstColumn[i-1][0] == firstColumn[i-2][0]) {
sheet.deleteRow(i);
}
}
}
Upvotes: 0
Views: 373
Reputation: 1832
Try changing the following line:
var firstColumn = sheet.getRange("W:W").getValues();
Upvotes: 1