I have a Google Sheet (let's call it Sheet A) with Date, Sku ID and Copy ID columns (among others). 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).
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.
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
}
})
}