Google Spreadsheet adding tooltip

I need to add a tooltip (mouser over a cell) in a Google spreadsheet.

I want the tooltip text to be taken from another cell, some idea?

Thanks in advance!google-apps-scriptgoogle-sheetsShareImprove this question Follow edited Jun 18 ’17 at 19:37Rubén 27k99 gold badges6161 silver badges140140 bronze badges asked Jun 17 ’17 at 10:23 sergio 18311 gold badge11 silver badge66 bronze badges

Add a comment

1 Answer

21

Consider using notes – they appear when you hover mouse over cells in a spreadsheet. You can add notes manually by clicking the right mouse button on a cell and selecting ‘insert note’. This can also be done programmatically.

Say, you’ve got 2 adjacent cells. We’ll use text from the second cell to add a note to the first one.

You can create the note with the text from the second cell using the following code.

function addNote() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  var targetCell = sheet.getRange("A1");
  var sourceCell = sheet.getRange("B1");

  var noteText = sourceCell.getValue();

  targetCell.setNote(noteText);

}

Here’s the end result after executing the function

You can modify the code to make it run only when the sheet is edited and dynamically update the note when the text in the source cell changes.

Leave a Comment