So I have a datarange "values" below. How can I simply find the duplicates within the datarange. I.E. rows C4/D4 says "something,here" and row C10/D10 says "something,here" it would log my 2 duplicates
function checkforDups() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Form Responses 1");
var values = sheet.getRange("C2:D100").getValues();
//Logger.log(values)
for (var i = 0; i < values.length; i ) {
Logger.log(values[i]);
}
}
CodePudding user response:
Find duplicates
function checkforDups() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName("Form Responses 1");
const vs = sh.getRange(2, 3, 99, 2).getDisplayValues();
let uA = [];
vs.forEach((r, i) => {
let x = r.join(',')
if (!~uA.indexOf(x)) {
uA.push((x));
} else {
sh.getRange(i 2, 1, 1, 2).setBackground("#ffff00");
}
});
}