Created
May 20, 2019 16:34
-
-
Save al-codaio/bbae27144db5f1f75b76794d6622b3f9 to your computer and use it in GitHub Desktop.
One-way data sync between Google Sheets files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sourceSpreadsheetID = "TO UPDATE"; | |
var sourceWorksheetName = "TO UPDATE"; | |
var targetSpreadsheetID = "TO UPDATE"; | |
var targetWorksheetName = "TO UPDATE"; | |
function importData() { | |
var thisSpreadsheet = SpreadsheetApp.openById(sourceSpreadsheetID); | |
var thisWorksheet = thisSpreadsheet.getSheetByName(sourceWorksheetName); | |
var thisData = thisWorksheet.getDataRange(); | |
//Uncomment line 11 below and comment out line 9 if you want to sync a named range. Replace "teamBugs" with your named range. | |
//var thisData = thisSpreadsheet.getRangeByName("teamBugs"); | |
var toSpreadsheet = SpreadsheetApp.openById(targetSpreadsheetID); | |
var toWorksheet = toSpreadsheet.getSheetByName(targetWorksheetName); | |
var toRange = toWorksheet.getRange(1, 1, thisData.getNumRows(), thisData.getNumColumns()) | |
toRange.setValues(thisData.getValues()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment