I'm trying to solve this question but despite the effort I have not advanced!
Every day I get a spreadsheet with two tabs of data. Each one has about 9 thousand rows. I need to capture the data from this worksheet and generate two new spreadsheets with one for "daily reporting" (with only the data of this day) and another for create a "database" (with all data previous results). How can I do this automatically with GAS?
I working in this code below so far, but when I will set the values in the new spreadsheet, I got error about range. :( I don't know how to declare that I want copy and set all the rows between 10 and the last with data from
function getData() {
var day = SpreadsheetApp.openById('XXXX');
var tab1 = day.getSheets()[0];
var tab2 = day.getSheets()[1];
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sss = ss.getSheets()[0];
var weeks = tab1.getRange("G8").getValues();
var dates = tab1.getRange("G9").getValues();
var regions = tab1.getRange('A10:A').getValues();
var locnames = tab1.getRange('B10:B').getValues();
var locnums = tab1.getRange('C10:C').getValues();
var divisions = tab1.getRange('D10:D').getValues();
var depnums = tab1.getRange('E10:E').getValues();
var depnames = tab1.getRange('F10:F').getValues();
var saless = tab1.getRange('G10:G').getValues();
var qtys = tab2.getRange('G10:G').getValues();
var datestart = sss.getRange('A2').setValues(dates);
var dateend = sss.getRange('B2').setValues(dates);
var week = sss.getRange('C2').setValues(weeks);
var region = sss.getRange('D2:D').setValues(regions);
var locname = sss.getRange('E2:E').setValues(locnames);
var locnum = sss.getRange('F2:F').setValues(locnums);
var division = sss.getRange('G2:G').setValues(divisions);
var depnum = sss.getRange('H10:H').setValues(depnums);
var depname = sss.getRange('I2:I').setValues(depnames);
var sales = sss.getRange('J2:J').setValues(saless);
var qty = sss.getRange('K2:K').setValues(qtys);
}
If anyone can help me, thank you immensely.
I put a spreadsheet in the link to illustrate the format of sheets and what I need to do. The first two tabs are the same as the ones I get. And in the next two tabs(daily_report, database) are the worksheets that I want to get separately with the code. https://docs.google.com/spreadsheets/d/1_iz0oansAfINosV2qNoDG0QMNpGS1bp1AL5kJQztRtc/edit?usp=sharing