I have two tabs in my sheet -- "Current" and "Futures".
Current is everything that has a date of TODAY. Futures are inputted well in advance, but when that date arrives (meaning -- input an order to take place on 3/7 on 3/1, then 3/7 arrives), I want the rows (only columns A to L) with MATCHING dates to move from FUTURES to CURRENT and append to the first blank cell in column A.
The rows should append, then be removed from FUTURES.
I have a "=TODAY" in cell Q1 of daily, and am matching column A of FUTURES to that.
My current script does not seem to make any action when I run it.
function copyIfMatched() {
var ss = SpreadsheetApp.openById("1eRO-30eIZamB5sjBp-Mz2QMKCfGxV037MQO8nS7G7AI");
var futures = ss.getSheetByName("Futures");
var daily = ss.getSheetByName("Daily");
var futuresData = futures.getRange("A3:L" + futures.getLastRow()).getValues();
var dailyMatchValue = daily.getRange("Q1").getValue();
var dailyData = daily.getDataRange().getValues();
for (var i = futuresData.length - 1; i >= 0; i--) {
if (futuresData[i][0] === dailyMatchValue) {
dailyData.push(futuresData[i].slice(0, 12));
futures.deleteRow(i + 3);
}
}
daily.getDataRange().clearContent();
daily.getRange(1, 1, dailyData.length, dailyData[0].length).setValues(dailyData);
}
The
Any advice as to what might be off?
I have a test sheet here, with a sample of the workflow.
There are two tabs, Daily & Futures - There is a date in Cell Q1 on Daily. If that cell matches any value in COLUMN A of FUTURES, that row on FUTURES should be MOVED to Daily. In other words, if the date matches, add it to the DAILY tab and remove it from the FUTURES:
https://docs.google.com/spreadsheets/d/1xWzwCwr052iHcyukirSm6wbq_WNFOoDR9ZqjOIfY85Q/edit?usp=sharing