I want to create a script to copy the active row of a sheet(TIME MACHINE) to another Google spreadsheet's sheet(Database). I also want to send "1" to the 13 row of the copied row. It would be great if anyone can guide me. The code given below only works to copy within the same spreadsheet.
function endTime() {
transfer("1E3CWWohirN4DD_f_23WWBElYrhqnAs_27crrxowFjFA", "TIME MACHINE", "TIME MACHINE2")
}
function transfer(targetId, sourceSheetName, targetSheetName) {
var d = new Date();
var offset = -d.getTimezoneOffset()/60;
var h = d.getHours();
var h = h >= 13? h - 12: h;
h = h == 0? 12: h;
var m = m < 10? "0" + d.getMinutes(): d.getMinutes();
var s = d.getSeconds();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = ss.getSheetByName(sourceSheetName);
var last = sourceSheet.getActiveRange().getRow();
var data = sourceSheet.getRange(last, 1, 1, 14).getValues();
var time1 = h + ":" + m + ":" + s;
sourceSheet.getRange(last, 28).setValue(time1);
var tamma = sourceSheet.getRange(last, 11).getValue();
// copy data
var ss2 = SpreadsheetApp.openById(targetId);
var targetSheet = ss2.getSheetByName(targetSheetName);
//get last row
var lastRow = targetSheet.getLastRow();
//write data
targetSheet.getRange(lastRow + 1, 1, data.length, data[0].length).setValues(data);
//write "1" into column 13
targetSheet.getRange(lastRow + 1, 13, data.length, 1).setValue("1");
targetSheet.getRange(lastRow + 1, 11, data.length, 1).setValue(tamma);
}
your code just needs a little reorganization and you need to get the right data from the source-sheet.
this should work:
function main() {
transfer("1mEluY-_K9oBvbxzASKn25YZ8BgF_naLl0XNitb4zIA8", "Sheet1", "Sheet1");
}
function transfer(targetId, sourceSheetName, targetSheetName) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = ss.getSheetByName(sourceSheetName);
var last = sourceSheet.getActiveRange().getRow();
var data = sourceSheet.getRange(last, 1, 1, 14).getValues();
// copy data
var ss2 = SpreadsheetApp.openById(targetId);
var targetSheet = ss2.getSheetByName(targetSheetName);
//get last row
var lastRow = targetSheet.getLastRow();
//write data
targetSheet.getRange(lastRow + 1, 1, data.length, data[0].length)
.setValues(data);
//write "1" into column 13
targetSheet.getRange(lastRow + 1, 13, data.length, 1)
.setValue("1")
}
Related
I have the following Google Apps Script which copies data from the source sheet and pastes it into another sheet. It currently looks for the last empty row and last empty column of the target sheet. I now have certain columns in the target sheet populated with formula to deal with the pasted data. The target sheet column range is A:K and has formula in columns I:K. in Can someone help me with new code to look for the last row where columns A:H are empty?
function onEdit(e) {
var spreadsheet = e.source;
var sheet = spreadsheet.getActiveSheet();
var sourcesheetname = "SOP Register"
var range = e.range;
var sheet = range.getSheet();
var row = range.getRow();
var column = range.getColumn();
var editedColumn = range.getColumn();
var editedRow = range.getRow();
var column = 7;
var date = range.getValue();
if(Object.prototype.toString.call(date) === '[object Date]' && editedColumn == column && editedRow > 2 && sheet.getName() == sourcesheetname) {
var targetsheetname = "Internal Audit Register";
var target = e.source.getSheetByName(targetsheetname);
var numCols = sheet.getLastColumn();
var values = sheet.getRange(row, 1, 1, numCols).getValues()[0];
values.splice(9) //Up to and including column I
values.splice(7, 1) //Remove column H
values.splice(2, 3); //Keep columns all columns and leave out columns C, D & E
var lastRow = target.getLastRow();
var lastCol = target.getLastColumn();
values.unshift("SOP"); //Append "SOP" to column A
target.appendRow(values); // Append new row
sheet.hideColumns(6,2);}}//End of onEdit Functions
After Tanaike's post I have added his function getLastRow(sheet) and all of my onEdit(e) script below:
function getLastRow(sheet) {
const values = sheet.getRange("A1:H" + sheet.getLastRow()).getDisplayValues();
let lastRow = 0;
for (let r = values.length - 1; r >= 0 ; r--) {
if (!lastRow && !values[r].every(e => e == "")) {
lastRow = r + 1;
break
}
}
return lastRow;
}
// Cut Employees Left from Unit Standards sheet and paste in Unit Standards - Employees Left sheet
function onEdit(e) {
var ss = e.source;
var sheet = ss.getActiveSheet();
var sheetName = "Unit Standards"
var range = e.range;
var editedColumn = range.getColumn();
var editedRow = range.getRow();
var column = 4;
var date = range.getValue();
// Object.prototype.toString.call(date) === '[object Date]' --> checks if value is date
// editedColumn == column && editedRow > 4 --> checks if edited cell is from 'Date Left'
// sheet.getName() == sheetName --> checks if edited sheet is 'Unit Standards'
if(Object.prototype.toString.call(date) === '[object Date]' && editedColumn == column && editedRow > 4 && sheet.getName() == sheetName) {
var numCols = sheet.getLastColumn();
var row = sheet.getRange(editedRow, 1, 1, numCols).getValues();
var destinationSheet = ss.getSheetByName("Unit Standards - Employees Left");
// Get first empty row:
var emptyRow = destinationSheet.getLastRow() + 1;
// Copy values from 'Unit Standards'
destinationSheet.getRange(emptyRow, 1, 1, numCols).setValues(row);
sheet.deleteRow(editedRow);
sheet.hideColumns(column); }
// Copy and paste from Events/Incidents sheet to Vehicle Damage sheet
{var range = e.range;
var sheet = range.getSheet();
var row = range.getRow();
var column = range.getColumn();
var sourcesheetname = "Events/Incidents";
var checkbox = range.getValue();
if (sheet.getName() == sourcesheetname && column == 25 && row > 2 && checkbox == true) {
var targetsheetname = "Vehicle Damage";
var target = e.source.getSheetByName(targetsheetname);
var numCols = sheet.getLastColumn();
var values = sheet.getRange(row, 1, 1, numCols).getValues()[0];
values.splice(17)
values.splice(8, 8)
values.splice(5, 1)
values.splice(3, 1); // Removing undesired values
var lastRow = target.getLastRow();
var lastCol = target.getLastColumn();
target.appendRow(values); }// Append new row
//SOP Internal Audit Required CheckBox if True
{var range = e.range
var sheet = range.getSheet();
var row = range.getRow();
var column = range.getColumn();
var sourcesheetname = "SOP Register";
var checkbox = range.getValue();
if (sheet.getName() == sourcesheetname && column == 5 && row > 2 && checkbox == true) {
sheet.showColumns(6,2);
sheet.getRange("F3").activate();}
// Copy and paste from SOP Register sheet to Internal Audit sheet
{var spreadsheet = e.source;
var sheet = spreadsheet.getActiveSheet();
var sourcesheetname = "SOP Register"
var range = e.range;
var sheet = range.getSheet();
var row = range.getRow();
var column = range.getColumn();
var editedColumn = range.getColumn();
var editedRow = range.getRow();
var column = 7;
var date = range.getValue();
if(Object.prototype.toString.call(date) === '[object Date]' && editedColumn == column && editedRow > 2 && sheet.getName() == sourcesheetname) {
var targetsheetname = "Internal Audit Register";
var target = e.source.getSheetByName(targetsheetname);
var numCols = sheet.getLastColumn();
var values = sheet.getRange(row, 1, 1, numCols).getValues()[0];
values.splice(9) //Up to and including column I
values.splice(7, 1) //Remove column H
values.splice(2, 3); //Keep columns all columns and leave out columns C, D & E
var lastRow = getLastRow(target);
var lastCol = target.getLastColumn();
values.unshift("SOP"); //Append "SOP" to column A
target.appendRow(values); // Append new row
sheet.hideColumns(6,2);}}}}}//End of onEdit Functions
This is my desired outcome and to paste the new data in cells A5:F5 but the current script is pasting it into cells A6:F6 and cells I6:K6 are empty:
Unwanted Outcome
A Sample of the source sheet and the target sheet are below:
Sample Spreadsheet
I believe your goal as follows.
You have a sheet which has the values in the columns "A" to "K". And the columns "I" to "K" have the formulas.
You want to retrieve the numbers of last row in the range of "A:H".
For this, how about this answer? In this answer, I prepare a function for retrieving the last row you want.
Modified script:
Please add the following function. This function returns the values of lastRow by inputting a sheet object.
function getLastRow(sheet) {
const values = sheet.getRange("A1:H" + sheet.getLastRow()).getDisplayValues();
let lastRow = 0;
for (let r = values.length - 1; r >= 0 ; r--) {
if (!lastRow && !values[r].every(e => e == "")) {
lastRow = r + 1;
break
}
}
return lastRow;
}
And, in order to use above function in your script, please modify as follows.
From:
var lastRow = target.getLastRow();
To:
var lastRow = getLastRow(target);
By this, lastRow can be retrieved in the range of "A:H".
Reference:
every()
Added 1:
About one more modification, please test the following modification. In your current script, lastRow retrieved by getLastRow(target) is not used and values is appended to the last row of the sheet by appendRow. So in order to use lastRow, please modify as follows. In this case, from your updated question, please modify getRange("A1:H" + sheet.getLastRow()) to getRange("A1:F" + sheet.getLastRow()) for the function of getLastRow.
From:
var lastRow = getLastRow(target);
var lastCol = target.getLastColumn();
values.unshift("SOP"); //Append "SOP" to column A
target.appendRow(values); // Append new row
To:
var lastRow = getLastRow(target);
var lastCol = target.getLastColumn();
values.unshift("SOP");
target.getRange(lastRow + 1, 1, 1, values.length).setValues([values]); // Modified
Added 2:
You have a sheet which has the values in the columns "A" to "K". And the columns "I" to "K" have the formulas.
You want to retrieve the numbers of last row in the range of "A:H".
And also, you want to copy the formulas of the columns "I" to "K" to the same row which puts the values.
For this, please modify your script as follows. In this case, please use above getLastRow().
From:
var lastRow = getLastRow(target);
var lastCol = target.getLastColumn();
values.unshift("SOP"); //Append "SOP" to column A
target.appendRow(values); // Append new row
To:
var lastRow = getLastRow(target);
var lastCol = target.getLastColumn();
values.unshift("SOP");
target.getRange(lastRow + 1, 1, 1, values.length).setValues([values]); // Modified
if (lastRow >= 3) target.getRange(lastRow, 9, 1, 3).copyTo(target.getRange(lastRow + 1, 9, 1, 3), SpreadsheetApp.CopyPasteType.PASTE_FORMULA); // Added
In this case, at least, it is required to have the row 3 has the formulas at the columns "I" to "K".
If the row 3 has surely the formulas at the columns "I" to "K", I think that you can also use if (lastRow >= 3) target.getRange(3, 9, 1, 3).copyTo(target.getRange(lastRow + 1, 9, 1, 3), SpreadsheetApp.CopyPasteType.PASTE_FORMULA);.
I have a Google Spreadsheet and have modified the code below as indicated to send an email alert 7 days before the date condition is due. This works perfectly, however it only looks at the first sheet and the spreadsheet contains 23 sheets in total. I think I need to include an array and loop the code but cannot work this out so would appreciate some help! Thanks in advance.
function checkReminder() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// set the first sheet as active
SpreadsheetApp.setActiveSheet(spreadsheet.getSheets()[0]);
// fetch this sheet
var sheet = spreadsheet.getActiveSheet();
// figure out what the last row is
var lastRow = sheet.getLastRow();
// the rows are indexed starting at 1, and the first row
// is the headers, so start with row 2
var startRow = 7;
// grab column 14 (the 'days left' column)
var range = sheet.getRange(7, 14, lastRow - startRow + 1, 1);
var numRows = range.getNumRows();
var days_left_values = range.getValues();
// Now, grab the reminder name column
range = sheet.getRange(7, 15, lastRow - startRow + 1, 1);
var reminder_info_values = range.getValues();
// Now, grab the deceased name column
range = sheet.getRange(3, 1);
var name_of_sheet = range.getValue();
var warning_count = 0;
var msg = "";
// Loop over the days left values
for (var i = 0; i <= numRows - 1; i++) {
var days_left = days_left_values[i][0];
if (days_left == 7) {
// if it's exactly 7, do something with the data.
var reminder_name = reminder_info_values[i][0];
msg = msg + "Reminder: " + name_of_sheet + " inscription work is due in " + days_left + " days.\n";
warning_count++;
}
}
if(warning_count) {
MailApp.sendEmail("my#email.com",
"Reminder Inscription Schedule Message", msg);
}
};
I want to send email reminder if the date columns is 7 or 1 days away from today. I have already made the script and what i want to add is it should consider others columns too, not only 1 with one script, for sending reminder for respective columns.
For eg:
It should remind for Plan Date, Plan Date 1, Plan Date 2 and Plan Date 3.
Please see the Sample Attached.
Script:
function checkReminder() {
// get the spreadsheet object
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// fetch this sheet
var sheet = spreadsheet.getSheets()[0];
// figure out what the last row is
var lastRow = sheet.getLastRow();
// figure out what the last column is
var lastCol = sheet.getLastColumn();
// the rows are indexed starting at 1, and the first row
// is the headers, so start with row 2
var startRow = 2;
// the columns are indexed starting at 2, and the first column
// is the headers, so start with column 2
var startCol = 2;
// grab column 3 (the 'days left' column)
var range = sheet.getRange(2,3,lastRow-startRow+1,1 );
var numRows = range.getNumRows();
var days_left_values = range.getValues();
// Now, grab the reminder name column
range = sheet.getRange(2, 1, lastRow-startRow+1, 1);
var reminder_info_values = range.getValues();
// Now, grab the first row
range = sheet.getRange(1, 2, lastCol-startCol+1, 1);
var column_info_values = range.getValues();
var warning_count = 0;
var msg = "";
// Loop over the days left values
for (var i = 0; i <= numRows - 1; i++) {
var days_left = days_left_values[i][0];
if(days_left == 1) {
// if it's exactly 1, do something with the data.
var reminder_name = reminder_info_values[i][0];
var column_name = column_info_values[0][0];
msg = msg + "Reminder: "+reminder_name+" - "+column_name+" is due in "+days_left+" day.\n";
warning_count++;
}
}
for (var i = 0; i <= numRows - 1; i++) {
var days_left = days_left_values[i][0];
if(days_left == 7) {
// if it's exactly 7, do something with the data.
var reminder_name = reminder_info_values[i][0];
var column_name = column_info_values[0][0];
msg = msg + "Reminder: "+reminder_name+" - "+column_name+" is due in "+days_left+" days.\n";
warning_count++;
}
}
if(warning_count) {
MailApp.sendEmail("myidsample#gmail.com",
"Reminder Spreadsheet Message", msg);
}
};
You're currently fetching only single column and processing that only.
In order to make this script run over other columns too, you'll need to loop through them, fetch data and then process them one by one.
Here you're fetching data from 3rd column :
// grab column 3 (the 'days left' column)
var range = sheet.getRange(2,3,lastRow-startRow+1,1 );
var numRows = range.getNumRows();
var days_left_values = range.getValues();
Like wise you can run a loop till last column and fetch data from 3rd, 5th, 7th .. columns and keep processing them.
So the code goes like this
function checkReminder() {
// get the spreadsheet object
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// fetch this sheet
var sheet = spreadsheet.getSheets()[0];
// figure out what the last row is
var lastRow = sheet.getLastRow();
// figure out what the last column is
var lastCol = sheet.getLastColumn();
// the rows are indexed starting at 1, and the first row
// is the headers, so start with row 2
var startRow = 2;
// the columns are indexed starting at 2, and the first column
// is the headers, so start with column 2
var startCol = 2;
// Now, grab the reminder name column
range = sheet.getRange(2, 1, lastRow - startRow + 1, 1);
var reminder_info_values = range.getValues();
// Now, grab the first row
range = sheet.getRange(1, 2, lastCol - startCol + 1, 1);
var column_info_values = range.getValues();
var warning_count = 0;
var msg = "";
for (var u = 3; u <= lastCol; u += 2) {
// grab the day's left column
var range = sheet.getRange(2, u, lastRow - startRow + 1, 1);
var numRows = range.getNumRows();
var days_left_values = range.getValues();
// Loop over the days left values
for (var i = 0; i <= numRows - 1; i++) {
var days_left = days_left_values[i][0];
if (days_left == 1) {
// if it's exactly 1, do something with the data.
var reminder_name = reminder_info_values[i][0];
var column_name = column_info_values[0][0];
msg = msg + "Reminder: " + reminder_name + " - " + column_name + " is due in " + days_left + " day.\n";
warning_count++;
}
}
for (var i = 0; i <= numRows - 1; i++) {
var days_left = days_left_values[i][0];
if (days_left == 7) {
// if it's exactly 7, do something with the data.
var reminder_name = reminder_info_values[i][0];
var column_name = column_info_values[0][0];
msg = msg + "Reminder: " + reminder_name + " - " + column_name + " is due in " + days_left + " days.\n";
warning_count++;
}
}
if (warning_count) {
MailApp.sendEmail("myidsample#gmail.com",
"Reminder Spreadsheet Message", msg);
}
}
}
This is un-tested code, let me know if any issue arises. I'll be happy to help you.
Thank you!
I am writing one of my first scripts, and have tried to look at other similar questions.
I have two sheets:
sheet1: new data (Only Column C is of interest, everything else can ignore in other columns)
sheet2: old data (but needs to be updated with sheet1 new data if not already there). The data to be added should be at the end of Column C after the existing data.
The code I have has the following compiling error.
I need to - get the last row of Column C Sheet2. Then check if Column C sheet1 is present in ColumnC sheet2, if not present- copy over from sheet1 to sheet2 column C.
UPDATED CODE:
function updateSheet() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = "Sheet1";
var destinationSheet = "Sheet2";
var source_sheet = ss.getSheetByName(sourceSheet);
var target_sheet = ss.getSheetByName(destinationSheet);
var last_row = CountColC();
//assumes headers in row 1
var r = target_sheet.getRange(1,2, lastRow - 1);
//Note the use of an array
r.sort([{column: 3, ascending: true}]);
// Process sheet
_updateSpreadsheet(source_sheet, target_sheet);
}
//gets last row in Column C
function CountColC(){
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
for(var i = data.length-1 ; i >=0 ; i--){
if (data[i][2] != null && data[i][2] != ''){
return i+1 ;
}
}
}
function _updateSpreadsheet(source_sheet, target_sheet) {
var last_row = CountColC();
var source_data = source_sheet.getDataRange().getValues();
var target_data = target_sheet.getDataRange().getValues();
var resultArray = [];
for (var n = 1 ; n < source_data.length ; n++) {
var keep = true;
for(var p = 1 ; p < target_data.length ; p++) {
if (new Date(source_data[n][2]).getTime() == new Date(target_data[p][2]).getTime()) {
keep = false; break;
}
}
Logger.log(keep);
if(keep){ resultArray.push([source_data[n][2]])};
}
last_row++;
Logger.log(resultArray);
target_sheet.getRange(last_row,1,resultArray.length,resultArray[2].length).setValues(resultArray);
// target_data.push(n);
}
Thanks in advance :)
function updateSheet() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = "Sheet1";
var destinationSheet = "Sheet2";
var source_sheet = ss.getSheetByName(sourceSheet);
var target_sheet = ss.getSheetByName(destinationSheet);
var lastCol = target_sheet.getLastColumn();
var lastRow = target_sheet.lastColumn();
//assumes headers in row 1
var r = target_sheet.getRange(2,1, lastRow - 1, 3);
//Note the use of an array
r.sort([{column: 3, ascending: true}]);
// Process sheet
_updateSpreadsheet(source_sheet, target_sheet);
}
//gets last row in Column C
function CountColC(){
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
for(var i = data.length-1 ; i >=0 ; i--){
if (data[i][2] != null && data[i][2] != ''){
return i+1 ;
}
}
}
function _updateSpreadsheet(source_sheet, target_sheet) {
var last_row = target_sheet.CountColC();
var source_data = source_sheet.getDataRange().getValues();
var target_data = target_sheet.getDataRange().getValues();
var resultArray = [];
for (var n = 1 ; n < source_data.length ; n++) {
var keep = true;
for(var p = 1 ; p < target_data.length ; p++) {
if (new Date(source_data[n][2]).getTime() == new Date(target_data[p][2]).getTime()) {
keep = false; break;
}
}
Logger.log(keep);
if(keep){ resultArray.push([source_data[n][2]])};
}
last_row++;
Logger.log(resultArray);
target_sheet.getRange(last_row,1,resultArray.length,resultArray[2].length).setValues(resultArray);
// target_data.push(n);
}
Instead call
var last_row = target_sheet.CountColC();
Please use
var last_row = CountColC();
i want to analyze a sheet (name: 1) for a value (e.g. 1) and post some values from these rows with this value in another sheet (name: 2).
"search for all cells in column F which got the value (e.g. 1). copy columns A, E and G (if F is 1) and post it at the end of sheet 2.
My Script just post one result actually. Could you please help me? I think i just dont get any kind of loop?
function checkWS() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
SpreadsheetApp.setActiveSheet(spreadsheet.getSheetByName("1"));
var sheet = spreadsheet.getActiveSheet();
// figure out what the last row is
var lastRow = sheet.getLastRow();
// the rows are indexed starting at 1, and the first row
// is the headers, so start with row 2
var startRow = 2;
// grab column 5 (the 'month left' column)
var range = sheet.getRange(2, 6, lastRow - startRow + 1, 1);
var numRows = range.getNumRows();
var soll_values = range.getValues();
// Now, grab the reminder name column
range = sheet.getRange(2, 1, lastRow - startRow + 1, 1);
var branch_values = range.getValues();
// and the count column
range = sheet.getRange(2, 7, lastRow - startRow + 1, 1);
var count_values = range.getValues();
var warning_count = 0;
var msg = "";
// Loop over the days left values
for (var i = 0; i <= numRows - 1; i++) {
var soll = soll_values[i][0];
if (soll == 1) {
// if it's exactly 1, do something with the data.
var name = branch_values[i][0];
var count = count_values[i][0];
warning_count++;
}
}
if (warning_count) {
var ss = SpreadsheetApp.openById("1vn4xTwdNk7E1Av4VNugtW6KWgZns2LzKS1lN1F6CTPw");
var Tab = ss.getSheetByName('2');
var lastRow = Tab.getLastRow();
Tab.getRange(lastRow + 1, 1).setValue(name);
Tab.getRange(lastRow + 1, 5).setValue(count);
Tab.getRange(lastRow + 1, 10).setValue(new Date());
SpreadsheetApp.flush();
}
}
now it's done. I just worked with a little helping-coloumn:
function checkWS() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
SpreadsheetApp.setActiveSheet(spreadsheet.getSheetByName("NAME"));
var sheet = spreadsheet.getActiveSheet();
// figure out what the last row is
var lastRow = sheet.getLastRow();
// the rows are indexed starting at 1, and the first row
// is the headers, so start with row 2
var startRow = 6;
// grab date (the 'month left' column)
var range = sheet.getRange(6, 54, lastRow - startRow + 1, 1);
var numRows = range.getNumRows();
var soll_values = range.getValues();
// Now, grab the branch column
range = sheet.getRange(6, 11, lastRow - startRow + 1, 1);
var branch_values = range.getValues();
// and the count column
range = sheet.getRange(6, 49, lastRow - startRow + 1, 1);
var count_values = range.getValues();
var warning_count = 0;
var msg = "";
// Loop over the days left values
for (var i = 0; i <= numRows - 1; i++) {
var soll = soll_values[i][0];
if (soll == 1) {
// if it's exactly 1, do something with the data.
var name = branch_values[i][0];
var count = count_values[i][0];
warning_count++;
// if (warning_count) { -> not needed
var ss = SpreadsheetApp.openById("ID");
var Tab = ss.getSheetByName('NAME_other_ss');
var lastRow = Tab.getLastRow();
Tab.getRange(lastRow + 1, 10).setValue(name);
Tab.getRange(lastRow + 1, 14).setValue(count);
Tab.getRange(lastRow + 1, 20).setValue(new Date());
SpreadsheetApp.flush();
// }
}
}
}