Google Script to Sort Full Rows Based on a Column Change

function onEdit(event){
  var sheet = event.source.getActiveSheet();
  var editedCell = sheet.getActiveCell();

  var columnToSortBy = 37;
  var columnToSortByValue = 'AK';
  var lastRow = lastValue(columnToSortByValue);
  
  var tableRange = "A3:AK"+lastRow; // What to sort.
  
  if(editedCell.getColumn() == columnToSortBy){   
    var range = sheet.getRange(tableRange);
    range.sort( { column : columnToSortBy, ascending: true } );
  }
}

function lastValue(column) {
  var lastRow = SpreadsheetApp.getActiveSheet().getMaxRows();

Google Script for BNR Currency

function GetBNRCurrency(currency) {
  var url = 'http://www.bnr.ro/nbrfxrates.xml';
  var xml = UrlFetchApp.fetch(url).getContentText();
  var document = XmlService.parse(xml);
  var root = document.getRootElement();
  var atom = XmlService.getNamespace('http://www.bnr.ro/xsd');

  var entries = document.getRootElement().getChild('Body', atom).getChild('Cube', atom).getChildren('Rate', atom);
  Logger.log(entries);
  
  for (var i = 0; i < entries.length; i++) {
    var el = entries[i];
    if (el.getAttribute('currency').getValue() == currency) {

User login

Subscribe to Drupal RSS