0

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);
    }
  }
}

1 Answer 1

1

Try changing the following line:

var firstColumn = sheet.getRange("W:W").getValues();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.