0
0
Google Sheetsspreadsheet~20 mins

Triggers (onEdit, onOpen) in Google Sheets - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Trigger Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📊 Formula Result
intermediate
2:00remaining
What happens when onEdit trigger modifies a cell?

You have a Google Sheets script with an onEdit(e) trigger that changes the value of cell B1 whenever any cell in column A is edited.

If you edit cell A2, what will be the value of B1 after the script runs?

Google Sheets
function onEdit(e) {
  var sheet = e.source.getActiveSheet();
  var range = e.range;
  if (range.getColumn() == 1) { // column A
    sheet.getRange('B1').setValue('Edited');
  }
}
AB1 will show 'Edited'
BThe script will cause an error
CB1 will show the edited cell's value
DB1 will be empty
Attempts:
2 left
💡 Hint

Think about what the script does when a cell in column A is edited.

Function Choice
intermediate
1:30remaining
Which trigger runs when the spreadsheet is opened?

You want to run a script automatically every time your Google Sheets file is opened. Which function name should you use?

Afunction onEdit()
Bfunction onOpen()
Cfunction onChange()
Dfunction onLoad()
Attempts:
2 left
💡 Hint

Think about the trigger that activates when the file opens.

🎯 Scenario
advanced
2:30remaining
Avoiding infinite loops in onEdit triggers

You wrote an onEdit(e) trigger that changes cell B1 whenever any cell in column B is edited. But when you edit B2, the script runs repeatedly and freezes your sheet.

Why does this happen?

Google Sheets
function onEdit(e) {
  var sheet = e.source.getActiveSheet();
  var range = e.range;
  if (range.getColumn() == 2) { // column B
    sheet.getRange('B1').setValue('Updated');
  }
}
ABecause column B is protected
BBecause the script has a syntax error
CBecause onEdit triggers only run once per edit
DBecause changing B1 triggers onEdit again, causing an infinite loop
Attempts:
2 left
💡 Hint

Think about what happens when the script edits a cell inside onEdit.

data_analysis
advanced
2:00remaining
Detecting which cell was edited in onEdit trigger

In an onEdit(e) trigger, you want to find the address of the edited cell to log it.

Which expression gives the correct cell address (like 'B3')?

Ae.source.getActiveCell().getA1Notation()
Be.range.getRow() + e.range.getColumn()
Ce.range.getA1Notation()
De.value
Attempts:
2 left
💡 Hint

Check the event object properties for the edited range.

🧠 Conceptual
expert
3:00remaining
Why use installable triggers instead of simple triggers?

Simple triggers like onEdit(e) run automatically but have restrictions. Which is a key reason to use installable triggers instead?

AInstallable triggers can access user data and perform actions requiring authorization
BInstallable triggers run faster than simple triggers
CInstallable triggers can only run on mobile devices
DInstallable triggers do not require any authorization
Attempts:
2 left
💡 Hint

Think about what simple triggers cannot do due to security limits.