Skip to content

Instantly share code, notes, and snippets.

@kikoso
Created June 5, 2021 11:44
Show Gist options
  • Save kikoso/35f1d2871b5659682f641e58730cb0b1 to your computer and use it in GitHub Desktop.
Save kikoso/35f1d2871b5659682f641e58730cb0b1 to your computer and use it in GitHub Desktop.
function copyPortfolioValue() {
var rangeToLog = 'Investment!B71:F71';// this is where the data tocopy is located
var sheetToLogTo = 'Value';// this is the name of new sheet we want to copy to
var ss = SpreadsheetApp.getActive();// getting th spreadsheetvar
valuesToLog = ss.getRange(rangeToLog).getValues();// getting the desired data
var logSheet = ss.getSheetByName(sheetToLogTo);// getting the sheet to copy
if (!logSheet) {// just in case you didn’t createit
logSheet = ss.insertSheet(sheetToLogTo);
}
var rowToAppend = valuesToLog.reduce(function (a, b) { return a.concat(b); })// format data
logSheet.appendRow(rowToAppend);// copy the desired data to the new sheet
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment