Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9843

How to copy range from one sheet to another column with offset

$
0
0

I have a range of data on sheet5 which needs to be copied and inserted 27 columns in from the end of sheet1. I can get it to insert the column in the right place but it doesn't copy the data. I am new to scripting so any advice would be of great help.

Here is code I am using:

function store() {
  var ss = SpreadsheetApp.getActiveSpreadsheet ();

  var source = ss.getRange ("Sheet5!D4:D80");

  var destSheet = ss.getSheetByName("Sheet1");

  var lastCol = destSheet.getLastColumn() -27;

  destSheet.insertColumnAfter(lastCol);

  source.copyTo(destSheet.getRange(lastCol + 1,1), {contentsOnly: true});

  SpreadsheetApp.getUi().alert('Played today Recorded');
}

Viewing all articles
Browse latest Browse all 9843

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>