Google Apps Script: Move data between spreadsheets - google-apps-script

I'm trying to use Google Apps Script to move data between two Google spreadsheets.
The spreadsheet named Ex_ID has one sheet and one row for each employee, each row has six important values including an id number and five data values.
The spreadsheet named CR_ID has a different sheet for each employee and each sheet has an id number and five cells where I need to enter the data.
I'm trying to write a script that moves data values from Ex_ID to CR_ID where the id values match. (Note: Since I'm still trying to see how the code can work, I limited the example to one of the five data values and I'm only testing it on three employees.)
function myFunction() {
var CR_ID = "1BbAmoSsS_2-nvOxv_l5gZ8ftXclD5muWs0ZAmkDUR-Y";
var ssCR = SpreadsheetApp.openById(CR_ID);
var sCR = ssCR.getSheets();
var Ex_ID = "1lkpXdWdbfe8Wkj1RGQOb-pWjEQe41hstKj2i4TxMQd8";
var ssEx = SpreadsheetApp.openById(Ex_ID);
var sEx = ssEx.getSheetByName('Sheet1');
for (var i = 2; i = 4; i++) {
//Get id value from Ex_ID
var ExCell = sEx.getRange(i, 2).getValue();
for (var j = 0; j = 2; j++) {
var sheet = sCR[j];
//Get id value from CR_ID
var val = sheet.getRange(1, 7).getValue();
if (ExCell[i] == val[j]) {
var ExWrite = sEx.getRange(i, 11).getValue();
sheet.getRange(3, 20).setValue(ExWrite);
}
}
}
}
Best,
Mayne Dela

I don't know how your data is organized and where you want to put them on the sheets but I would try something like this:
function myFunction()
{
var ess = SpreadsheetApp.openById("1BbAmoSsS_2-nvOxv_l5gZ8ftXclD5muWs0ZAmkDUR-Y");
var es = ess.getSheets();
var dss = SpreadsheetApp.openById("1lkpXdWdbfe8Wkj1RGQOb-pWjEQe41hstKj2i4TxMQd8");
var ds = dss.getSheetByName('Sheet1');
var dr = ds.getDataRange();
var dA = dr.getValues();
for(var i=1;i<dA.length;i++)//started with 1 assuming that you have a header.
{
var row=dA[i];//loop through rows of employee data I will assume data to be in this ID,DataValue1,DataValue2,DataValue3,DataValue4,DataValue5
for(var j=0;j<es.length;j++)
{
if(row[0]==es[j].getSheetName())//checking the ID value assuming it is row[0];
{
var sht=es[j];
sht.getRange('D1').setValue(row[1]);//DataValue1
sht.getRange('D2').setValue(row[2]);//DataValue2
etc...
}
}
}
}

Related

Combine Multiple Sheets to One Dynamic Master [duplicate]

How can I merge multiple tabs in a Google Spreadsheet using Google App Script ? Data in all the tabs keep changing.
For example, I have 'Sheet1', 'Sheet2' and 'Sheet3' in a Google spreadsheet. Data in all these sheets have 3 columns - Name and email ID & Region. Now, I want to merge/combine the data present in these 3 sheets/tabs into a 4th Sheet i.e. 'Sheet 4' having same Columns (name, email Id & Region). The 4th sheet should have data as - data of Sheet1 followed by Sheet2 and then Sheet3. The number of rows in all the 3 sheets keeps changing.
=query({Sheet1!A1:C; Sheet2!A1:C; Sheet3!A1:C}, "where Col1 is not null", 0)
I wouldn't use a script for this; the worksheet formulas are much faster, at least most of the time.
Make sure you use semicolons to separate the ranges. Semicolons are the End_Of_Row operator for array literals.
If you really want to use a script...
function combineSheets() {
var sApp = SpreadsheetApp.getActiveSpreadsheet();
var s1= sApp.getSheetByName("Sheet1");
var s2= sApp.getSheetByName("Sheet2");
var s3= sApp.getSheetByName("Sheet3");
var s4= sApp.getSheetByName("Sheet4");
// If Sheet4 doesn't exist you'll need to create it here.
var s1values = s1.getRange(1,1,s1.getLastRow(),3).getValues();
var s2values = s2.getRange(1,1,s2.getLastRow(),3).getValues();
var s3values = s3.getRange(1,1,s3.getLastRow(),3).getValues();
// Now, we can put out all together and stuff it in Sheet4
var s4values = [];
s4values = s1values.concat(s2values,s3values);
s4.getRange(1,1,s4values.length,3).setValues(s4values);
}
You don't need a script for this. In the fourth sheet, enter the following formula in A2:
={filter(Sheet1!A2:C, len(Sheet1!A2:A)); filter(Sheet2!A2:C, len(Sheet2!A2:A)); filter(Sheet3!A2:C, len(Sheet3!A2:A))}
It returns the contents of columns A-C where the entry in column A is nonempty, and stacks them in one array.
You can use Google Apps Scripts for this.
var ss = SpreadsheetApp.getActiveSpreadsheet();
function TotalsSheet() {
var totaldata = [];
var sheets = ss.getSheets();
var totalSheets = 2;
for (var i=0; i < totalSheets; i++) {
var sheet = sheets[i];
var range = sheet.getDataRange();
var values = range.getValues();
for (var row in values) {
totaldata.push(values[row]);
}
}
return totaldata;
}
function Start() {
var All = ss.insertSheet("All-Values");
var totaldata = TotalsSheet();
for (var i = 0; i < totaldata.length; i++) {
All.appendRow(totaldata[i]);
}
}
//This Script is must faster
function consolidateData(){
// defined all variables
var sheetNames = [];
var dataSheet = [];
var dataValues = [];
var conso=[];
var header = [["Name","email ID","Region"]];
var ws = SpreadsheetApp.getActiveSpreadsheet();
// get all sheets
var allsheets = ws.getSheets();
for(var s in allsheets){
var sheet = allsheets[s];
sheetNames[s] = sheet.getName();
dataSheet[s] = ws.getSheetByName(sheetNames[s]);
// adding all sheet's data to a single variable
conso = conso.concat(dataSheet[s].getRange("A2:C"+dataSheet[s].getLastRow()).getValues());
}
// writing data into new sheet
var newSheet = ws.insertSheet().setName("Consolidated_Data");
newSheet.getRange("A1:C1").setValues(header);
newSheet.getRange("A2:C"+(conso.length+1)).setValues(conso);
}
I made one that will do nine tabs' consolidation, with more rows and columns.
=filter({{Sheet1!A1:Q500};{Sheet2!A1:Q500};{Sheet3!A1:Q500};{Sheet4!A1:Q500};{Sheet5!A1:Q500};{Sheet6!A1:Q500};{Sheet7!A1:Q500};{Sheet8!A1:Q500};{Sheet9!A1:Q500}},{{Sheet1!A1:A500};{Sheet2!A1:A500};{Sheet3!A1:A500};{Sheet4!A1:A500};{Sheet5!A1:A500};{Sheet6!A1:A500};{Sheet7!A1:A500};{Sheet8!A1:A500};{Sheet9!A1:A500}}<>"")
I'm wondering if it is a way to generalize the initial filter formula so that you can cut and paste in more sheet numbers, so for instance if there were 20 or 30 tabs with 25 columns, could you consolidate that easily into one page?

Google App Scripts Merging Data from multiple Sheets [duplicate]

How can I merge multiple tabs in a Google Spreadsheet using Google App Script ? Data in all the tabs keep changing.
For example, I have 'Sheet1', 'Sheet2' and 'Sheet3' in a Google spreadsheet. Data in all these sheets have 3 columns - Name and email ID & Region. Now, I want to merge/combine the data present in these 3 sheets/tabs into a 4th Sheet i.e. 'Sheet 4' having same Columns (name, email Id & Region). The 4th sheet should have data as - data of Sheet1 followed by Sheet2 and then Sheet3. The number of rows in all the 3 sheets keeps changing.
=query({Sheet1!A1:C; Sheet2!A1:C; Sheet3!A1:C}, "where Col1 is not null", 0)
I wouldn't use a script for this; the worksheet formulas are much faster, at least most of the time.
Make sure you use semicolons to separate the ranges. Semicolons are the End_Of_Row operator for array literals.
If you really want to use a script...
function combineSheets() {
var sApp = SpreadsheetApp.getActiveSpreadsheet();
var s1= sApp.getSheetByName("Sheet1");
var s2= sApp.getSheetByName("Sheet2");
var s3= sApp.getSheetByName("Sheet3");
var s4= sApp.getSheetByName("Sheet4");
// If Sheet4 doesn't exist you'll need to create it here.
var s1values = s1.getRange(1,1,s1.getLastRow(),3).getValues();
var s2values = s2.getRange(1,1,s2.getLastRow(),3).getValues();
var s3values = s3.getRange(1,1,s3.getLastRow(),3).getValues();
// Now, we can put out all together and stuff it in Sheet4
var s4values = [];
s4values = s1values.concat(s2values,s3values);
s4.getRange(1,1,s4values.length,3).setValues(s4values);
}
You don't need a script for this. In the fourth sheet, enter the following formula in A2:
={filter(Sheet1!A2:C, len(Sheet1!A2:A)); filter(Sheet2!A2:C, len(Sheet2!A2:A)); filter(Sheet3!A2:C, len(Sheet3!A2:A))}
It returns the contents of columns A-C where the entry in column A is nonempty, and stacks them in one array.
You can use Google Apps Scripts for this.
var ss = SpreadsheetApp.getActiveSpreadsheet();
function TotalsSheet() {
var totaldata = [];
var sheets = ss.getSheets();
var totalSheets = 2;
for (var i=0; i < totalSheets; i++) {
var sheet = sheets[i];
var range = sheet.getDataRange();
var values = range.getValues();
for (var row in values) {
totaldata.push(values[row]);
}
}
return totaldata;
}
function Start() {
var All = ss.insertSheet("All-Values");
var totaldata = TotalsSheet();
for (var i = 0; i < totaldata.length; i++) {
All.appendRow(totaldata[i]);
}
}
//This Script is must faster
function consolidateData(){
// defined all variables
var sheetNames = [];
var dataSheet = [];
var dataValues = [];
var conso=[];
var header = [["Name","email ID","Region"]];
var ws = SpreadsheetApp.getActiveSpreadsheet();
// get all sheets
var allsheets = ws.getSheets();
for(var s in allsheets){
var sheet = allsheets[s];
sheetNames[s] = sheet.getName();
dataSheet[s] = ws.getSheetByName(sheetNames[s]);
// adding all sheet's data to a single variable
conso = conso.concat(dataSheet[s].getRange("A2:C"+dataSheet[s].getLastRow()).getValues());
}
// writing data into new sheet
var newSheet = ws.insertSheet().setName("Consolidated_Data");
newSheet.getRange("A1:C1").setValues(header);
newSheet.getRange("A2:C"+(conso.length+1)).setValues(conso);
}
I made one that will do nine tabs' consolidation, with more rows and columns.
=filter({{Sheet1!A1:Q500};{Sheet2!A1:Q500};{Sheet3!A1:Q500};{Sheet4!A1:Q500};{Sheet5!A1:Q500};{Sheet6!A1:Q500};{Sheet7!A1:Q500};{Sheet8!A1:Q500};{Sheet9!A1:Q500}},{{Sheet1!A1:A500};{Sheet2!A1:A500};{Sheet3!A1:A500};{Sheet4!A1:A500};{Sheet5!A1:A500};{Sheet6!A1:A500};{Sheet7!A1:A500};{Sheet8!A1:A500};{Sheet9!A1:A500}}<>"")
I'm wondering if it is a way to generalize the initial filter formula so that you can cut and paste in more sheet numbers, so for instance if there were 20 or 30 tabs with 25 columns, could you consolidate that easily into one page?

I need to split a Google Sheet into multiple tabs (sheets) based on column value

I have searched many possible answers but cannot seem to find one that works. I have a Google Sheet with about 1600 rows that I need to split into about 70 different tabs (with about 20-30 rows in each one) based on the value in the column titled “room”. I have been sorting and then cutting and pasting but for 70+ tabs this is very tedious.
I can use the Query function but I still need to create a new tab, paste the function and update the parameter for that particular tab.
This script seemed pretty close:
ss = SpreadsheetApp.getActiveSpreadsheet();
itemName = 0;
itemDescription = 1;
image = 2;
purchasedBy = 3;
cost = 4;
room = 5;
isSharing = 6;
masterSheetName = "Master";
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Update Purchases')
.addItem('Add All Rows To Sheets', 'addAllRowsToSheets')
.addItem('Add Current Row To Sheet', 'addRowToNewSheet')
.addToUi();
}
function addRowToNewSheet() {
var s = ss.getActiveSheet();
var cell = s.getActiveCell();
var rowId = cell.getRow();
var range = s.getRange(rowId, 1, 1, s.getLastColumn());
var values = range.getValues()[0];
var roomName = values[room];
appendDataToSheet(s, rowId, values, roomName);
}
function addAllRowsToSheets(){
var s = ss.getActiveSheet();
var dataValues = s.getRange(2, 1, s.getLastRow()-1, s.getLastColumn()).getValues();
for(var i = 0; i < dataValues.length; i++){
var values = dataValues[i];
var rowId = 2 + i;
var roomName = values[room];
try{
appendDataToSheet(s, rowId, values, roomName);
}catch(err){};
}
}
function appendDataToSheet(s, rowId, data, roomName){
if(s.getName() != masterSheetName){
throw new Error("Can only add rows from 'Master' sheet - make sure sheet name is 'Master'");
}
var sheetNames = [sheet.getName() for each(sheet in ss.getSheets())];
var roomSheet;
if(sheetNames.indexOf(roomName) > -1){
roomSheet = ss.getSheetByName(roomName);
var rowIdValues = roomSheet.getRange(2, 1, roomSheet.getLastRow()-1, 1).getValues();
for(var i = 0; i < rowIdValues.length; i++){
if(rowIdValues[i] == rowId){
throw new Error( data[itemName] + " from row " + rowId + " already exists in sheet " + roomName + ".");
return;
}
}
}else{
roomSheet = ss.insertSheet(roomName);
var numCols = s.getLastColumn();
roomSheet.getRange(1, 1).setValue("Row Id");
s.getRange(1, 1, 1, numCols).copyValuesToRange(roomSheet, 2, numCols+1, 1, 1);
}
var rowIdArray = [rowId];
var updatedArray = rowIdArray.concat(data);
roomSheet.appendRow(updatedArray);
}
But I always get an unexpected token error on line 51 or 52:
var sheetNames = [sheet.getName() for each(sheet in ss.getSheets())];
(And obviously the column names, etc. are not necessarily correct for my data, I tried changing them to match what I needed. Not sure if that was part of the issue.)
Here is a sample of my data: https://docs.google.com/spreadsheets/d/1kpD88_wEA5YFh5DMMkubsTnFHeNxRQL-njd9Mv-C_lc/edit?usp=sharing
This should return two separate tabs/sheets based on room .
I am obviously not a programmer and do not know Visual Basic or Java or anything. I just know how to google and copy things....amazingly I often get it to work.
Let me know what else you need if you can help.
Try the below code:
'splitSheetIntoTabs' will split your master sheet in to separate sheets of 30 rows each. It will copy only the content not the background colors etc.
'deleteTabsOtherThanMaster' will revert the change done by 'splitSheetIntoTabs'. This function will help to revert the changes done by splitSheetIntoTabs.
function splitSheetIntoTabs() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
var header = rows[0];
var contents = rows.slice(1);
var totalRowsPerSheet = 30; // This value will change no of rows per sheet
//below we are chunking the toltal row we have into 30 rows each
var contentRowsPerSheet = contents.map( function(e,i){
return i%totalRowsPerSheet===0 ? contents.slice(i,i+totalRowsPerSheet) : null;
}).filter(function(e){ return e; });
contentRowsPerSheet.forEach(function(e){
//crate new sheet here
var currSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet();
//append the header
currSheet.appendRow(header);
//populate the rows
e.forEach(function(val){
currSheet.appendRow(val);
});
});
}
// use this function revert the sheets create by splitSheetIntoTabs()
function deleteTabsOtherThanMaster() {
var sheetNotToDelete ='Master';
var ss = SpreadsheetApp.getActive();
ss.getSheets().forEach(function(sheet){
if(sheet.getSheetName()!== sheetNotToDelete)
{
ss.deleteSheet(sheet);
}
});
}
I was using Kessy's nice script, but started having trouble when the data became very large, where the script timed out. I started looking for ways to reduce the amount of times the script read/wrote to the spreadsheet (rather than read/write one row at a time) and found this post https://stackoverflow.com/a/42633934
Using this principle and changing the loop in the script to have a loop within the loop helped reduce these calls. This means you can also avoid the second call to append rows (the "else"). My script is a little different to the examples, but basically ends something like:
`for (var i = 1; i < theEmails.length; i++) {
//Ignore blank Emails and sheets created
if (theEmails[i][0] !== "" && !completedSheets.includes(theEmails[i][0])) {
//Set the Sheet name = email address. Index the sheets so they appear last.
var currentSheet = theWorkbook.insertSheet(theEmails[i][0],4+i);
//append the header
//To avoid pasting formulas, we have to paste contents
headerFormat.copyTo(currentSheet.getRange(1,1),{contentsOnly:true});
//Now here find all the rows containing the same email address and append them
var theNewRows =[];
var b=0;
for(var j = 1; j < rows.length; j++)
{
if(rows[j][0] == theEmails[i][0]) {
theNewRows[b]=[];//Initial new array
theNewRows[b].push(rows[j][0],rows[j][1],rows[j][2],rows[j][3],rows[j][4],rows[j][5],rows[j][6],rows[j][7]);
b++;
}
}var outrng = currentSheet.getRange(2,1,theNewRows.length,8); //Make the output range the same size as the output array
outrng.setValues(theNewRows);
I found a table of ~1000 rows timed out, but with the new script took 6.5 secs. It might not be very neat, as I only dabble in script, but perhaps it helps.
I have done this script that successfully gets each room and creates a new sheet with the corresponding room name and adding all the rows with the same room.
function myFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
// This var will contain all the values from column C -> Room
var columnRoom = sheet.getRange("C:C").getValues();
// This var will contain all the rows
var rows = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
//Set the first row as the header
var header = rows[0];
//Store the rooms already created
var completedRooms = []
//The last created room
var last = columnRoom[1][0]
for (var i = 1; i < columnRoom.length; i++) {
//Check if the room is already done, if not go in and create the sheet
if(!completedRooms.includes(columnRoom[i][0])) {
//Set the Sheet name = room (except if there is no name, then = No Room)
if (columnRoom[i][0] === "") {
var currentSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet("No Room");
} else {
var currentSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet(columnRoom[i][0]);
}
//append the header
currentSheet.appendRow(header);
currentSheet.appendRow(rows[i]);
completedRooms.push(columnRoom[i][0])
last = columnRoom[i][0]
} else if (last == columnRoom[i][0]) {
// If the room's sheet is created append the row to the sheet
var currentSheet = SpreadsheetApp.getActiveSpreadsheet()
currentSheet.appendRow(rows[i]);
}
}
}
Please test it and don't hesitate to comment for improvements.

How to copy bulk of data to a given range?

Hello so I am trying to get values from the 'book' sheet then copy it to 'Completed' sheet. It doesnt give any error but doesnt do the copying too. It takes the values form book stores it in the data array but doesnt copy them to the 'Completed' sheet. So I guess there is a problem with the last row.
var sheet = spreadsheet.getSheetByName('Book'); //source sheet
var Datarange = sheet.getRange('Q:Q'); //range to check
var Datavalue = (Datarange.getValues());
var dest = spreadsheet.getSheetByName('Completed'); //destination sheet
var data = [];
var j =[];
for (i=0; i<Datavalue.length;i++) {
if ( Datavalue[i] == "Completed") {
data.push.apply(data,sheet.getRange(i+1,1,1,24).getValues());
j.push(i);
}
}
dest.getRange(dest.getLastRow()+1,1,data.length,data[0].length).setValues(data); /// copy data to range
Something like this:
function whoknowswhat() {
var ss=SpreadsheetApp.getActive()
var sh=ss.getSheetByName('Book');
var rg=sh.getRange(1,17,sh.getLastRow(),1);
var v=rg.getValues();
var dest=ss.getSheetByName('Completed');
var data=[];
for (i=0; i<v.length;i++) {
if (v[i][?]=="Completed") {//need another parameter for column
data.push(v[i]);//v[i] is an entire row
}
}
dest.getRange(dest.getLastRow()+1,1,data.length,data[0].length).setValues(data);
}

Copying data between spreadsheets from sheets with the same name

I want to copy the cell with the daily score from the sheets of all of my students in a spreadsheet where they are calculated and collected to another spreadsheet where they are used as currency to buy rewards. Both spreadsheets contain a sheet for every student that is named after that student, e.g. "John Smith"
The original google script that I created worked, but it was poor coding because I had to repeat the coding for every single name, and therefore add a new paragraph of code every time we get a new student. I would like to create a new google script that is more elegant and powerful and works without specifying the students' names so that it never needs to be amended. I can't quite get it and keep hitting a "Syntax error" with the last line.
function ImportDailyScore() {
var dailyinput = "J27"; // Mon=J3, Tue=J9, Wed=J15, Thu=J21, Fri=J27
var dollaroutput = "B2"; // Today=B2, Yesterday=B3, etc.
var dollarspreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var checkinspreadsheet = SpreadsheetApp.openById('some id');
var checkinsheets = checkinspreadsheet.getSheets(); // get all the sheets from check in doc
var dollarsheets = dollarspreadsheet.getSheets(); // get all the sheets from dollar doc
for (var i=0; i<checkinsheets.length; i++){ // loop across all the checkin sheets
var checkindata = checkinsheets[i].getRange(dailyinput).getValue();
var namedcheckin = checkinsheets[i].getSheetName()
for (var j=0; j<dollarsheets.length; j++){
var nameddollar = dollarsheets[j].getSheetName();
if (namedcheckin = nameddollar, dollarsheets[j].getRange(dollaroutput).setValue(checkindata))
}
}
}
For reference, the original code (which works just as I would like it to) but needs to specify the name of every single student is:
function ImportDailyScore() {
var dollarspreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var checkinspreadsheet = SpreadsheetApp.openById('1Y9Ys1jcm1xMaLSqmyl_pFnvIzbf-omSeIcaI2FgjFIs');
var dailyinput = "J3"; // Mon=J3, Tue=J9, Wed=J15, Thu=J21, Fri=J27
var dollaroutput = "B4"; // Today=B2, Yesterday=B3, etc.
var JohnCHECKIN = checkinspreadsheet.getSheetByName('John Smith');
var JohnCHECKINData = JohnCHECKIN.getRange(dailyinput).getValue();
var JohnDOLLAR = dollarspreadsheet.getSheetByName('John Smith');
JohnDOLLAR.getRange(dollaroutput).setValue(JohnCHECKINData);
var JenniferCHECKIN = checkinspreadsheet.getSheetByName('Jennifer Scott');
var JenniferCHECKINData = JenniferCHECKIN.getRange(dailyinput).getValue();
var JenniferDOLLAR = dollarspreadsheet.getSheetByName('Jennifer Scott');
JenniferDOLLAR.getRange(dollaroutput).setValue(JenniferCHECKINData);
etc.
Try this:
I don't have enough information to know how to handle the dollaroutput programmatically.
function ImportDailyScore() {
var inputA=['','J3','J9','J15','J21','J27',''];
var dailyinput = inputA[new Date().getDay()];
if(dailyinput) {
var dollaroutput = "B2"; // Today=B2, Yesterday=B3, etc. Not sure how to handle this programmatically I'd have to see the sheet
var dollarspreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var checkinspreadsheet = SpreadsheetApp.openById('id');
var checkinsheets = checkinspreadsheet.getSheets(); // get all the sheets from check in doc
var dollarsheets = dollarspreadsheet.getSheets(); // get all the sheets from dollar doc
for (var i=0; i<checkinsheets.length; i++){ // loop across all the checkin sheets
var checkindata = checkinsheets[i].getRange(dailyinput).getValue();
var namedcheckin = checkinsheets[i].getSheetName();
for (var j=0; j<dollarsheets.length; j++){
var nameddollar = dollarsheets[j].getSheetName();
if (namedcheckin == nameddollar) {
dollarsheets[j].getRange(dollaroutput).setValue(checkindata);
}
}
}
}else{
SpreadsheetApp.getUi().alert(Utilities.formatString('Today is %s no school.', Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "E")));
}
}