Google Spreadsheet Adding Tooltip

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!

1

1 Answer

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.

8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.