Answers for "google sheets script onedit sort for multiple sheets"

1

google sheets script onedit sort for multiple sheets

function onEdit(event){
  	var ss = SpreadsheetApp.getActiveSpreadsheet();
  	var sheet = event.source.getActiveSheet().getName()
  	var editedCell = event.range.getSheet().getActiveCell();
	if(sheet=="Loan Inquiries"){
  		var columnToSortBy = 2;
  		var tableRange = "A3:T99"; //range to be sorted
  		if(editedCell.getColumn() == columnToSortBy){   
    		var range = ss.getActiveSheet().getRange(tableRange); 
    		range.sort( { column : columnToSortBy, ascending: true } );
  		}
    }
  	else if(sheet=="Deals in Escrow"){
    	var columnToSortBy = 7;
    	var tableRange = "A3:T99"; //range to be sorted
  		if(editedCell.getColumn() == columnToSortBy){   
     		var range = ss.getActiveSheet().getRange(tableRange); 
    		range.sort( { column : columnToSortBy, ascending: true } );
  		}
    }
  	else{return}
}
Posted by: Guest on April-11-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language