Google Apps Script Spreadsheet Comment Automation

There is no way to manipulate Comments via Spreadsheet Services – see Issue 36756650. (Star it if you wish.)

Instead, all the “Comments” methods work on Notes.

The following method will append a new “Modified” timestamp to any existing one – not quite as nice looking as an actual Comment would be, unfortunately.

function onEdit() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
  var cell = sheet.getActiveCell();
  var comments = cell.getComment();
  // Newline works in msgBox, but not in Note.
  comments = comments + "\\nModified: " + (new Date());
  //Browser.msgBox(comments);
  cell.setComment(comments);
}

Leave a Comment