Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9704

How to run scripts on multiple sheets of Google Sheets

$
0
0

Here's my code:

function transferNotes() {
  // Get notes (not comments) from the source spreadsheet
  var sourceSpreadheet = SpreadsheetApp.openById('1GdoTw3KxQO03xp5CiKX9VIJMZQfPMPbGdCa_PvnQaoI');
  var sourceTab = sourceSpreadheet.getSheetByName('SpA')
  var sourceRange = sourceTab.getRange('D2:D2000');
  var notes = sourceRange.getNotes();

  // Post the notes to the target spreadsheet
  var targetSpreadheet = SpreadsheetApp.openById('1YApnQ64OYFOYKQrefuxJ0gwpchAKRatWpJsSNLeevO4');
  var targetTab = targetSpreadheet.getSheetByName('SpB');
  var targetRange = targetTab.getRange('D2:D2000');
  targetRange.setNotes(notes); 
}

I want to run this code on multiple sheets at once and automatically update notes in real time without having to run the script every time to update it. Help me.


Viewing all articles
Browse latest Browse all 9704

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>