Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9832

How do I run multiple onEdit functions in the same spreadsheet in Google Sheets?

$
0
0

all! I hope I can count on your expertise to help me with a project I'm working on.

I want to call different functions based on which spreadsheet the event happened. Ex. Typing 1 in B6 on "Room Reservations" will call checkB6(). Typing 1 in E17 for "Supplies" will call checkE17().

Everything seemed to be working yesterday, and now it's not even though I did not change anything to onEdit(e).

Here is my code:


//When something is entered into the target cell, the appropriate function is called automatically
function onEdit(e){

var s = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();

if (s = "Room Requests") {
     e = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Room Requests").getRange("b8").getValue();
     checkB8();
} 



else if (s = "Car Requests") {
         e = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Car Requests").getRange("b9").getValue();
         checkB9();
} 



else if (s = "Supplies") {
         e = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Supplies").getRange("e17").getValue();
         checkE17();
} 

  //etc., etc., etc.

else {e = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Birthdays").getRange("b4").getValue();
   checkB4();
 }
}

Viewing all articles
Browse latest Browse all 9832

Latest Images

Trending Articles



Latest Images