I would like to copy and paste VALUES only from source sheet to target sheet using google scripts.
I have filter applied in the column so I am only looking to copy the cells that are present / filtered (not all values).
In the example that I have built, I have:
Source sheet (copy values from): Sheet1
Target sheet (paste values to): Sheet2
Sheet1 screenshot:
Process / Steps:
When I select any particular color in "Fav_color" in column A..let's say "yellow".
Now, Members are filtered accordingly.
On the button click, I want my google script function to run that copies the filtered Member Names and paste it in Sheet2.
Problem:
In Sheet 2: I am getting column heading / title as well "Member Name" while I only want member names (not the actual column name).
I do know the problem as in my code, I am copying complete B column but I do not know how to exclude column heading / title.
function transfer() {
var sss = SpreadsheetApp.getActiveSpreadsheet();
var ss = sss.getSheetByName('Sheet1');
var range = ss.getRange('A1:A');
var data = range.getValues();
var tss = SpreadsheetApp.getActiveSpreadsheet();
var ts = tss.getSheetByName('Sheet2');
ts.getRange('A:A').clearContent();
ts.getRange('A:A').clearContent();
ss.getRange("B:B").copyTo(ts.getRange("A2"), {contentsOnly:true});
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…