[英]Copy a raw from sheet 'source' to another sheet 'destination' adding the date in the first column of the row Google spreadsheet
hey i would like to create a script that copy a row from a sheet to an other sheet each time i start the function so it will take the range of (H35:N35) sheet 'Bilan' and paste it in the first empty row of a column except the column 'A' in sheet "Stock", the column 'A' will be used to write the Date (its for backing up the stocks of some goods each week ) the result is that i will get: Date of the first week | 嘿,我想创建一个脚本,每当我启动该功能时,将一行从一张纸复制到另一张纸,这样它将使用(H35:N35)一张纸'Bilan'的范围并将其粘贴到除“股票”工作表中“ A”列以外的其他列,“ A”列将用于写入日期(用于每周备份某些商品的库存),结果是:我将获得:第一周 the stock row Date of the second week`|
第二周的库存行日期 the stock row
股票行
I edited some scripts to work but i didn't succeed so am looking for your help 我编辑了一些脚本以使其正常工作,但未成功,因此正在寻求您的帮助
Thank You 谢谢
Here you go. 干得好。 It's pretty simple it copys from Bilan!H35:N35 to the first empty row of Stock and it starts in column B for the full length of the input range.
从Bilan!H35:N35复制到Stock的第一行是非常简单的,并且从B列开始输入整个输入范围。
function rangeCopy()
{
var ss=SpreadsheetApp.getActive();
var sh1=ss.getSheetByName('Bilan');
var sh2=ss.getSheetByName('Stock');
var rg1=sh1.getRange('H35:N35');
var rg2=sh2.getRange(sh2.getLastRow()+1,2,1,rg1.getWidth());
rg1.copyTo(rg2);
}
Thanks For the help Cooper ,and for adding the date to the first cell in each pasted raw i used this : 感谢Cooper的帮助,并且将日期添加到每个粘贴的原始文件的第一个单元格中,我使用了这个:
function rangeCopy()
{
var ss=SpreadsheetApp.getActive();
var sh1=ss.getSheetByName('Bilan');
var sh2=ss.getSheetByName('Backup');
var rg1=sh1.getRange('H35:N35');
var rg2=sh2.getRange(sh2.getLastRow()+1,2,1,rg1.getWidth());
rg1.copyTo(rg2,{contentsOnly:true});
}
function DateNow()
{
var sss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Backup');
var date = new Date;
var RangeIndex = sss.getLastRow() ;
sss.getRange('A'+ RangeIndex).setValue(date.getMonth() + 1 + "/" + date.getDate() + "/" + date.getFullYear());
}
function onOpen()
{
SpreadsheetApp.getUi()
.createMenu('Custom Menu')
.addItem('Transfer Row', 'start')
.addToUi()
}
function start()
{
rangeCopy()
DateNow()
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.