I want to copy / paste only the values from the source range, not the contained functions or formatting. The option contentsOnly at the end of the script below is supposed to achive this, but actually it doesn´t. Does anyone see the problem?
Thanks so much!
function copyactiverowcontentsOnly() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var target = SpreadsheetApp.openById("1JwBik0vu3LTxCOTDpMUVSw5n6YxWz3BxZoLsx")
var source_sheet = ss.getSheetByName('not listed');
var target_sheet = target.getSheetByName('pairing');
var source_range = source_sheet.getActiveRange();
var target_range = target_sheet.getRange('A2:Q2');
source_range.copyTo(target_range),{contentsOnly:true};
};
CodePudding user response:
Use that
source_range.copyTo(target_range, SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
CodePudding user response:
Try this:
function copyactiverowcontentsOnly() {
const ss = SpreadsheetApp.getActive();
const tss = SpreadsheetApp.openById("1JwBik0vu3LTxCOTDpMUVSw5n6YxWz3BxZoLsx")
const ssh = ss.getSheetByName('not listed');
const tsh = tss.getSheetByName('pairing');
const vs = ssh.getActiveRange().getDisplayValues();
const trg = tsh.getRange('A2:Q2');
tsh.getRange(2, 1, vs.length, vs[0].length).setValues(vs);
};