Removing Duplicate Rows if Data in Columns B-F are Identical

So for this problem I have data in columns A-G and I need to remove entire rows with duplicate information in rows B-F:

function urlsToSheets(){
    importData("", "Pavement Condition");

function importData(url, sheetName) {
    let requiredColumns;
      if (url == ""){
        requiredColumns = [0, 3, 11, 12, 13, 14, 30]; 
    const res = UrlFetchApp.fetch(url);
    const ar = Utilities.parseCsv(res.getContentText());
    const values = => => r[i]));
    const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
    sheet.getRange(1, 1, values.length, values[0].length).setValues(values);
    // sheet.getDataRange().removeDuplicates("B:B","F:F");

This script is actually written for 5 URLs and 5 Separate sheets, but I’ve simplified it for one URL/sheet in this example.

I know my syntax for removing duplicates is incorrect, but I’m not sure if this is a one-line type of problem or if I’ll need to use a loop of some kind.

Any help is appreciated. Thank you!

>Solution :

As the docs say, use

    .getRange(1, 1, values.length, values[0].length)

Leave a Reply