Paste Special Values in Google Sheet Script

The following will paste special values in Google Sheet Script. This avoids transferring the formats. Here contentOnly is set True. It is an important criterion.

function moveValuesOnly() {
var ss1 = SpreadsheetApp.getActiveSpreadsheet();
var source1 = ss1.getRange('Sheet1!A1:A3');
source1.copyTo(ss1.getRange('Sheet2!A1'), {contentsOnly: true});
//source1.clear();
}

If there only one cell to transfer you can make use setValue() property as is as follows:

function moveValuesOnly() {
var ss1 = SpreadsheetApp.getActiveSpreadsheet();
var source1 = ss1.getRange('Sheet1!A1');
//source1.copyTo(ss1.getRange('Sheet2!A1'), {contentsOnly: true});
ss.getRange('Sheet2!A1').setValue(source.getValue());
//source1.clear();
}

https://stackoverflow.com/questions/16090447/paste-special-values

You must be logged in to post a comment.