[英]How to search for yesterday's date in a row, then copy / paste values to new Google Sheet
I have a Google Sheet (let's call it Sheet A) with Date, Sku ID and Copy ID columns (among others).我有一个带有日期、Sku ID 和 Copy ID 列(以及其他列)的 Google 表格(我们称之为表格 A)。 I would like to write a bit of JavaScript in Apps Script that will search the Date column of Sheet A for yesterday's date, then copy that cell, plus the Sku ID and Copy ID from that row into another sheet (Sheet B).
我想在 Apps 脚本中写一点 JavaScript,它将在工作表 A 的日期列中搜索昨天的日期,然后复制该单元格以及该行中的 Sku ID 和复制 ID 到另一个工作表(工作表 B)中。
I already have a function that adds new rows to Sheet B, I just need to copy the data from yesterday into those new rows.我已经有一个 function 将新行添加到工作表 B,我只需要将昨天的数据复制到这些新行中。
Right now my thought process is:现在我的思考过程是:
Am I on the right track?我在正确的轨道上吗? Any pointers on how to actually write that?
关于如何实际编写的任何指示? Am I over complicating/simplifying?
我过度复杂化/简化了吗?
function lfunko() {
const ss = SpreadsheetApp.getActive();
const sr = 2;//data start row
const sh = ss.getActiveSheet();
const[hA,...vs] = sh.getDataRange().getValues();//assume one header
const ydv = new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()-1).valueOf();
vs.foEach((r,i) => {
let dt = new Date(r[0]);
let dtv = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate()).valueOf();
if(ydv == dtv) {
//this is one of yesterdays rows
//row is i + sr
}
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.