function highlightDuplicates() {
var sheets = SpreadsheetApp.getActive().getSheets();
var duplicates = {};
for (var i = 0; i < sheets.length; i++) {
var sheet = sheets[i];
var data = sheet.getDataRange().getValues();
for (var j = 0; j < data.length; j++) {
for (var k = 0; k < data[j].length; k++) {
var cell = data[j][k];
if (duplicates[cell]) {
sheet.getRange(j + 1, k + 1).setBackground('yellow');
duplicates[cell].push([sheet.getSheetName(), j + 1, k + 1]);
} else if (cell) {
duplicates[cell] = [[sheet.getSheetName(), j + 1, k + 1]];
}
}
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter