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();

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

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

  //etc., etc., etc.

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

One of the problems of your code is that it's using the wrong syntax for comparisons as it's using = instead of == (abstract equality) or === (strict equality).

Another problem is that it's are overwritten e as it's first used for the edit event object but a cell value is assigned to this variable.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.