0

I am learning to use google app script. I have written code to get row number in which so far I succeeded but can't find a way to assign it to a cell or row change event trigger. Can someone help me figure out how to do this? My code is as follows :

function onChange(event) {  
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();  
var currentCell = sheet.getCurrentCell();  

sheet.getRange("B1").setValue(currentCell.getRow());  
}  
Rubén
  • 34,714
  • 9
  • 70
  • 166

2 Answers2

1

There are no "onSelect" trigger on Google Apps Script but you could use the poll technique. Basically, you will have to use a sidebar to hold client-side code that will check for the selected cell every determined time. For code examples checkout the following Q/A

Rubén
  • 34,714
  • 9
  • 70
  • 166
0

Have you installed the trigger? onChange triggers need to be explicitly hooked up because they're considered installable triggers (opposed to simple triggers, which just require saving the .gs file).

You can manage your triggers from the Menu in your Apps Script Editor: Edit > Current project's triggers

Kate
  • 1,263
  • 10
  • 13
  • Actually the event should trigger on selecting any cell, not on change, I realized it searching web, but still not sure of onSelection is simple or installable. – Attaullah Khan Feb 03 '19 at 04:34
  • To my knowledge, there’s no trigger for OnSelection at this time, but I hope you found a workaround for what you were trying to do! – Kate Aug 25 '19 at 15:37