[英]Insert new row at top of sheet based on new rows in another tab
I have a Google sheet with a listing of job candidates in one tab (Primary candidates sheet). 我有一个Google工作表,其中在一个标签中列出了应聘者列表(主要应聘者工作表)。 What I would like to do is paste a daily export of candidates into another tab and have new candidates from the latest export inserted up top of the primary candidates sheet.
我想做的是将候选人的每日导出粘贴到另一个选项卡,并将最新导出的新候选人插入到主要候选人表的顶部。
I've tried to search this methodology online which typically leads to success after some research. 我尝试过在线搜索此方法,通常会在进行一些研究后获得成功。 However, I can't seem to find any documentation on macros, scripts, or formulas which could accomplish this.
但是,我似乎找不到任何可以完成此操作的有关宏,脚本或公式的文档。
Wanted to see if anyone had any resources for additional research. 想看看是否有人有任何其他研究资源。
You can use below code to copy data from source sheet into top of destination sheet. 您可以使用以下代码将数据从源工作表复制到目标工作表的顶部。 Enter sheet names accordingly.
相应地输入工作表名称。 Save.
救。 From script editor menu, Run > Function > Test , to test.
从脚本编辑器菜单中, 运行>功能>测试进行测试。 It'll insert new rows in destination sheet and source sheet data will stay as is.
它将在目标工作表中插入新行,而源工作表数据将保持原样。
function test() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getSheetByName('source sheet name here'); // change here
var des = ss.getSheetByName('destination sheet name here'); // change here
var sv = source
.getDataRange()
.getValues();
sv.shift();
des.insertRowsAfter(1, sv.length);
des.getRange(2, 1, sv.length, source.getLastColumn()).setValues(sv);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.