Home > Mobile >  Google Sheets Format Pasting Across Sheets – Automated
Google Sheets Format Pasting Across Sheets – Automated

Time:10-06

How do I paste a formatted range from one sheet tab onto another sheet tab at a specific location. I know how to manually do this (CTRL C/V), but I want to run a function that'll do it for me on a button press. Does the range need to parallel desired placement in the "copy sheet". Is there a specific app script I can run that will let me paste formatting (i.e. blank grey and white stripes over time blocked hours from the previous week)? The cells themselves don't have any data in them. It's only the cell colors (and borders) I want to paste over.

CodePudding user response:

Basically it can be done with this short snipped:

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();         // current sheet
  var range = sheet.getRange('A1:D10');    // a source area
  
  var dest_sheet = ss.getSheets()[1];      // 2nd sheet in the spreadsheet
  range.copyTo(dest_sheet.getRange('A1')); // a left-top corner of a destination area
}
  • Related