Skip to content

Instantly share code, notes, and snippets.

@bactisme
Created October 20, 2022 07:25
Show Gist options
  • Save bactisme/8027f3baaa5b7743249f6a9a71100b5d to your computer and use it in GitHub Desktop.
Save bactisme/8027f3baaa5b7743249f6a9a71100b5d to your computer and use it in GitHub Desktop.
Configure the first function. Create a sketch of a button > right click > assign a script > copyPnL in the box > Enjoy
function copyPnL(){
var uri = "https://docs.google.com/spreadsheets/d/1pNObB_ETC";
var sheetname = "Sheet 1";
var range = "A1:BS500";
var offsetx = 1;
var offsety = 1;
COPYSHEET(uri, sheetname, range, offsetx, offsety);
}
function COPYSHEET(spreadsheet_uri, sheetname, range, offsetx = 1, offsety = 1){
var file = SpreadsheetApp.openByUrl(spreadsheet_uri);
var sheet = file.getSheetByName(sheetname);
var range = sheet.getRange(range);
var values = range.getValues();
SpreadsheetApp.getActive().getActiveSheet().getRange(offsetx, offsety,values.length, values[0].length).clear();
SpreadsheetApp.getActive().getActiveSheet().getRange(offsetx, offsety,values.length, values[0].length).setValues(values);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment