How to detect when user selects different cells in Google Sheets

I’m working on a Google Sheets project where I need to track which cells the user has currently selected. Whenever someone clicks on different cells or selects a new range, I want to update some text content to match that selection.

Is there any way to set up an event listener or function that gets called automatically when the user changes their cell selection? I’ve looked through the documentation but can’t find a clear solution for monitoring selection changes in real time.

Any suggestions on how to implement this functionality would be really helpful.

yeah, google sheets lacks direct event for selection changes. onEdit() helps but only on actual edits. maybe set up an apps script polling getSelection() regularly, but fair warning, it might lag a bit. good luck!

Been wrestling with this exact problem for months on a project tracking tool. Google Sheets just wasn’t built for real-time selection monitoring. I tried onSelectionChange() in Apps Script, but it only works reliably in custom cell functions - not as a standalone trigger. What actually worked was creating a sidebar HTML service that talks to the sheet through google.script.run. The sidebar detects focus changes and checks the active selection periodically without killing performance like server-side polling does. You’ll need SpreadsheetApp.getActiveSheet().getActiveRange() in your HTML service calls. It’s not perfect but gives you near real-time selection tracking without ruining the user experience.

Yeah, there’s no onSelectionChange event in Apps Script - super annoying. Hit the same wall last year building a dashboard. My workaround was a custom menu function that grabs the current selection when you click it manually. You could set up a time-driven trigger in onOpen() that checks getActiveRange() every few seconds, but that’ll kill performance. Or use onEdit() with custom functions that reference the active cell, but that only fires when someone actually edits something. If you need real-time selection tracking, you’ll probably have to ditch pure Apps Script and use the Sheets API with a web app.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.