Skip to content

Instantly share code, notes, and snippets.

@AkshaySapra
Created December 20, 2017 07:10
Show Gist options
  • Save AkshaySapra/dd96a90bb8b204596656d406b3398d83 to your computer and use it in GitHub Desktop.
Save AkshaySapra/dd96a90bb8b204596656d406b3398d83 to your computer and use it in GitHub Desktop.
Google sheets script for highlighting all duplicates, except for FIRST instance
//Modify the parameters i and j to capture the range of your sheet. J indicates rows and i indicates columns
function appendString() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var map = {};
for (var j = 1; j < 119; j++)
{
for (var i = 1; i < 10; i++)
{
var currentValue = sheet.getRange(j,i).getValue();
if (!currentValue==""){
if (currentValue in map)
{
sheet.getRange(j,i).setBackground("pink");
}
else
map[currentValue] = 1;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment