[英]Copy data from last row of master sheet and paste it in specific cells in another sheet in google sheets
I want to copy data from the last row of my master sheet which populates using a google form and paste it into a new sheet that is created when a form is submitted. 我想从使用Google表单填充的主表的最后一行复制数据,并将其粘贴到提交表单时创建的新表中。 Now, I want the new sheet to automatically put certain text in specific cells and copy data from the last row in some specific cells. 现在,我希望新工作表自动将某些文本放在特定的单元格中,并从某些特定的单元格的最后一行复制数据。 Example-: The master sheet 示例-: 主表
now i want to copy the data in cell b2 (assuming 2 is the last row) to newly created sheet in the cell b1 from cell c2 to b3 from cell d2 to b4 from cell AL2 to h20 and so on. 现在我想将单元格b2中的数据(假设2是最后一行)复制到单元格b1中从单元格c2到b3的新创建工作表,从单元格d2到单元格AL2到h20的b4,依此类推。 I am new to google appscript. 我是Google Appscript的新手。 Any help would be appreciated. 任何帮助,将不胜感激。
I don't what you meant by and so on. 我不是您的意思,依此类推。 But here's the instructions that you specified so far. 但是,这是您到目前为止指定的说明。
function copyMasterToNewSheet()
{
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sht=ss.getSheetByName('The Master Sheet');
var rng=sht.getDataRange();
var rngA=rng.getValues();
var row=rngA[rngA.length-1];
var newsht=ss.insertSheet(row[0]);//It's name is the TimeStamp
newsht.getRange('B1').setValue(row[1]);
newsht.getRange('B3').setValue(row[2]);
newsht.getRange('B4').setValue(row[3]);
newsht.getRange('H20').setValue(row[37]);
SpreadsheetApp.flush();
}
You would need to hook this up to the on Form Submit trigger. 您需要将其连接到“表单提交”触发器上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.