Skip to content

Instantly share code, notes, and snippets.

@zo0m
Last active March 19, 2016 17:34
Show Gist options
  • Select an option

  • Save zo0m/a72ca5d7bc6494239733 to your computer and use it in GitHub Desktop.

Select an option

Save zo0m/a72ca5d7bc6494239733 to your computer and use it in GitHub Desktop.
Google docs search
var statusColumnOffset = 0;
var range = SpreadsheetApp.getActiveSheet().getDataRange();
function setRowColors() {
for (var i = 0; i < range.getLastRow(); i++) {
findFrodOfIP(i);
}
}
function findFrodOfIP(ipIndex) {
var ipRowRange = range.offset(ipIndex, statusColumnOffset, 1);
var ip = ipRowRange.offset(statusColumnOffset, statusColumnOffset).getValue();
if (ip && ipRowRange.getBackgroundColor()) {
frodPartOfIP = ip.substr(0,11);
for (var i = 0; i < range.getLastRow(); i++) {
var rowRange = range.offset(i, statusColumnOffset, 1);
var ipCandidate = rowRange.offset(statusColumnOffset, statusColumnOffset).getValue();
if((ipIndex !== i) && ipCandidate && (ipCandidate.toString().match(frodPartOfIP)==frodPartOfIP)) {
rowRange.setBackgroundColor("red");
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment