copy cell values of named range in one sheet to same cell address of another named range in another sheet

StackOverflow https://stackoverflow.com/questions/16069529

Question

Is it possible to copy the values of a named range in one sheet and paste them in the same cell location of another sheet?

For example, I have named range "old_desk_1" in sheet1!A24:A25 and named range "desk_1" in sheet2!A24:A25. Is it possible to copy the values in the cells of old_desk_1 to desk_1 without just doing the standard copy/paste?

Was it helpful?

Solution

Yes it is, first I suggest looking at the following documentations.

The above links will tell you about all the methods available for all the classes you will need to do this. Here is a basic example of what you're hoping to acheive.

function copyCells(){
   var thisSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
   var theRange = thisSpreadsheet.getRangeByName("YOUR RANGE");

   var destinationSheet = thisSpreadsheet.getSheetByName("SHEET TO COPY TO");
   var destinationRange = destinationSheet.getRangeByName("YOUR OTHER RANGE");

   theRange.copyTo(destinationRange);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top