Created
April 26, 2022 05:12
-
-
Save neno-tech/59ba584dc4f8669ccb63e262a64cc895 to your computer and use it in GitHub Desktop.
โค้ด copy data from sheet to sheet
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
function copyData() { | |
importRange( | |
"xxx", | |
"yyy", | |
"xxx", | |
"yyy" ); | |
} | |
function importRange(sourceID, sourceRange, targetID, targetRange) { | |
const sourceSS = SpreadsheetApp.openById(sourceID); | |
const sourceRng = sourceSS. getRange (sourceRange); | |
const sourceVals = sourceRng.getValues(); | |
const targetSS = SpreadsheetApp.openById(targetID); | |
const targetRng = targetSS.getRange(targetRange); | |
const targetSheet = targetSS.getSheetByName(targetRng.getSheet().getName()); | |
targetSheet.clear () | |
const targetVals = targetSheet.getRange( | |
targetRng.getRow(), | |
targetRng.getColumn(), | |
sourceVals.length, | |
sourceVals[0].length | |
) | |
targetVals.setValues(sourceVals); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment