There's a sample over here that will show how to set the first's chart title to the active cell:

function onOpen(){
  SpreadsheetApp.getUi().createMenu('Charts').addItem('Update title of the first chart from active cell', 'myFunction').addToUi();
function myFunction() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var chart = sheet.getCharts()[0];
  chart = chart.modify()
  .setOption('title', sheet.getActiveCell().getValue() || 'Empty')

The script adds a menu and will update the first's chart title to the current active cell.

It would be interesting to do the contrary, for instance you may have multiple sheets and build charts from each sheet range. The script should allow to set the current selected chart's title to a give named cell.

Assuming the scenario above, and while a chart is selected, pseudocode:

  1. Get the sheet name from currently selected chart
  2. Use reference to cell to get text that will be used for the title, as a general rule each sheet shall have a cell named ChartTitle, therefore using the sheet name from step1 we should be allowed to build a correct reference
  3. Set the currently selected chart title to the returned text


  • Is there a function that will return the currently selected chart?
  • If so, is it possible to retrieve the range of the chart in a way the sheet name may be extracted?

The code is mine.

Unfortunately, we can't determine if the chart is currently active.

Still. Again.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.