0

I have two scripts that I am trying to run simultaneously that will organize two different columns based on their cell value. Both functions work, I'm just unsure how to combine the two

Could someone please help me?

function onEdit(e) {
  const src = e.source.getActiveSheet();
  const r = e.range;
  if (r.columnStart != 9 || r.rowStart == 1 || e.value == src.getName()) return;
  const dest = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(e.value);
  src.getRange(r.rowStart,1,1,9).moveTo(dest.getRange(dest.getLastRow()+1,1,1,9));
  src.deleteRow(r.rowStart);

}

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Opened");            
var range = sheet.getRange("J2:J100");                  
 
function onEdit(e)  {
 range.sort([{column: 10, ascending: false}]);        
}

I have tried combining both formulas however, I am aware that I cannot have two onEdit functions. 
  • Please explain what each one is supposed to do and trigger event is supposed to trigger it and what sheet is the active sheet – Cooper Dec 01 '22 at 22:38
  • the first script moves the entire row to the second sheet when the status in column "I" is selected as "Closed." The second script is to sort column J on sheet 1 (labelled open) ascending: false(Z-A) which is to make all dates in that column in order from the more recent date Here's the link to an example of the sheet I'm working on https://docs.google.com/spreadsheets/d/1RCGx0SYnEB6obd9l6p7zaz7TVXPxP1IiYuvCcSHD_qk/edit?usp=sharing – Kassandra Bowes Dec 02 '22 at 13:48
  • I don't understanding and I don't follow links to spreadsheets – Cooper Dec 02 '22 at 18:01

0 Answers0