Writing on notes a value from another cell automatically through App Script [Google Sheet]

Viewed 88

I'm trying to get a specific value on the notes of all the cells of a specific column, but since notes don't support formulas I'm trying to get this through Apps Script.

I'm new to it so I'm still kinda clueless about the syntax and I can't find a proper example of what I wanna do.

I made this, which is actually creating a note when I edit any cell in the 12th column but the value reported on the note is "Range" instead of what I'm expecting (the value of the cell on the 13th column).

 function onEdit(e) {
   if(e.range.columnStart === 12){
   var cell = SpreadsheetApp.getActiveSheet().getActiveCell();
   cell.setNote(cell.offset(0,0));
 }
}
1 Answers

In that case, how about the following modification? offset returns the Class Range. So in this case, getValue is used for retrieving the value.

From:

cell.setNote(cell.offset(0,0));

To:

cell.setNote(cell.offset(0, 1).getValue());
  • In this modification, the value of the neighbour to the right cell is retrieved and set it as a note. So, from if (e.range.columnStart === 12) {}, in this case, the value of column "M" is retrieved.

Reference:

Related