Home > Enterprise >  Make a cell in google sheets automatically 'insert comment'
Make a cell in google sheets automatically 'insert comment'

Time:08-24

I don't think I explained it well, column L is where I can log what I have done - with a date and time, so say I send a message, I would log MESSAGE SENT then say I make a call I could log CALLED and any info I wanted to remember - each entry being date and time stamped

enter image description here

In the image you can see the comment field - all i want is that to pop up when I click on the cell and be able to add to the comment field

CodePudding user response:

You can use the onSelectionChange(e) trigger and check if the selected cell(s) fall into your criteria, if so then insert comment.

https://developers.google.com/apps-script/guides/triggers

CodePudding user response:

You could use this sample script to set a comment on an edited cell:

function onEdit(e){
  var range = e.range;
  range.setNote('Last modified: '   new Date());
} 

However this requires that you edit the content of the cell to trigger the onEdit() function. Which you can modify instead to trigger the function manually (or assign the script to an image to act as a button) like so.

function setComment() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.getRange('L14:L16').setNote('Last modified: '   new Date()); 
}

Reference:

https://developers.google.com/apps-script/reference/spreadsheet/range#setNote(String) https://developers.google.com/apps-script/guides/triggers#onedite

  • Related