Skip to content

Instantly share code, notes, and snippets.

@bram-atmire
Created July 19, 2019 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bram-atmire/7ce51506e7d676f57918a2dfb231ae94 to your computer and use it in GitHub Desktop.
Save bram-atmire/7ce51506e7d676f57918a2dfb231ae94 to your computer and use it in GitHub Desktop.
Google Sheets: Remove authority keys from selected cells
function onOpen() {
SpreadsheetApp.getUi().createMenu("Atmire")
.addItem('Remove Authorities','removeAuthorities')
.addToUi();
}
function removeAuthorities() {
var activeSheet = SpreadsheetApp.getActiveSheet();
var selection = activeSheet.getSelection();
var range = selection.getActiveRange();
var numRows = range.getNumRows();
var numCols = range.getNumColumns();
for (var i = 1; i <= numRows; i++) {
for (var j = 1; j <= numCols; j++) {
var currentValue = range.getCell(i,j).getValue();
var regExp = new RegExp("::.+?::600",'gi');
var authoritiesRemoved = currentValue.replace(regExp,'');
range.getCell(i,j).setValue(authoritiesRemoved);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment