简体   繁体   English

将原始数据从工作表“源”复制到另一个工作表“目的地”,并在Google电子表格行的第一列中添加日期

[英]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.

相关问题 Google电子表格将值从一行复制到另一张工作表 - Google spreadsheet copy values from one row to another sheet 将一行从一个Google表格电子表格复制到表单提交中的另一表格 - Copy a row from one Google Sheet Spreadsheet to Another on Form Submit 谷歌脚本将数据从工作表 1 复制到第一个空行工作表 2 - google script copy data from sheet 1 to first empty row sheet 2 将特定范围复制到从一个工作表到另一个工作表中的第一个空行和特定列 - Copy a specific range to from one sheet to the first empty row and specific column in another sheet 将工作表复制到另一个电子表格[Google Apps脚本] - Copy sheet to another spreadsheet [Google Apps Script] 从工作表 A 复制行并将其附加到 Google 工作表的工作表 B 中 - Copy Row From Sheet A and append it in Sheet B in Google Sheet 根据 Google Sheet 脚本第一列合并单元格中的日期从工作表锁定异常中删除行 - Remove rows from sheet lock exception based on date in merged cell in first column in Google Sheet script 将范围从一个工作表复制到Google工作表中的另一个工作表 - Copy a range from one sheet to another in google sheet 从另一个电子表格访问Google工作表图像onClick句柄 - Accessing google sheet images onClick handle from another spreadsheet Google脚本:将行复制到另一张工作表中进行编辑 - Google Script: Copy row to another sheet on edit ALMOST THERE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM