Reputation: 7
In Google Spreadsheets i try to copy some selected cells to another place in the sheet with Google Scripteditor. I have this code, but it doesn't work:
function kopieerDag() {
var sheet = SpreadsheetApp.getActiveSheet();
Logger.log(sheet);
var selection = sheet.getSelection();
// var values = selection.getValues();
Logger.log(selection);
selection.copyTo(sheet.getRange(1, 1), {contentsOnly: true});
}
any ideas? thx for the help!
Upvotes: 1
Views: 60
Reputation: 201388
The reason of error in your script is that getSelection()
is not directly returned the range object. Please use getActiveRange()
for getSelection()
. So can you try this modification?
var selection = sheet.getSelection();
var selection = sheet.getSelection().getActiveRange();
Upvotes: 2