can anyone help me get sheet by name before the if conditional? I'm trying to limit the range to column C on a specific sheet and right now it gets triggered by all sheets.
function sendMailEdit(e){
if (e.range.columnStart!= 3 || e.value != "REMOVAL") return;
const rData = e.source.getActiveSheet().getRange(e.range.rowStart,1,1,14).getValues();
let n = rData[0][3];
let f = rData[0][1];
let d = rData[0][13];
let items = rData[0][2];
let now = new Date().toLocaleString("en-US");
let msg = "This is an auto generated message to inform you that the removal date of " + f + " for project " + n + " (" + d + ") has been added to the Logistics Schedule at " + now;
Logger.log(msg);
GmailApp.sendEmail("x#x.com", "Project Removal Scheduled", msg)
}
I tried adding getSheetByName on line 3 and the trigger still worked with all other sheets but with no data. Also on line 2 I added e.source.set or get SheetByName etc no success.
function sendMailEdit(e){
const sh = e.range.getSheet();
if (sh.getName() != "Your sheet name" && e.range.columnStart!= 3 || e.value != "REMOVAL") return;
const rData = e.source.getActiveSheet().getRange(e.range.rowStart,1,1,14).getValues();
let n = rData[0][3];
let f = rData[0][1];
let d = rData[0][13];
let items = rData[0][2];
let now = new Date().toLocaleString("en-US");
let msg = "This is an auto generated message to inform you that the removal date of " + f + " for project " + n + " (" + d + ") has been added to the Logistics Schedule at " + now;
Logger.log(msg);
GmailApp.sendEmail("x#x.com", "Project Removal Scheduled", msg)
}
Related
I'm looking to run an automated email script, but exclude two specific tabs, named "Data" and "Carpet". I wrote this to test on just the "Data" tab, but couldn't get it to work.
I have excluded the sheet url and email address for purpose of posting.
Edit - rest of the code works fine, just want to prevent it from running on the specified tabs above
`
function autoemail(e) {
let sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
let range = e.range;
let row = e.range.getRow();
let col = e.range.getColumn();
let cellValue = sheet.getActiveCell().getValue();
let address = sheet.getRange(row,1).getValue();
let ordernumber = sheet.getRange(row,2).getValue();
let installdate = sheet.getRange(row,3).getValue();
let jobtype = sheet.getRange(row,4).getValue();
let fieldsuper = sheet.getRange(row,5).getValue();
let notes = sheet.getRange(row,11).getValue();
let holdstatus = sheet.getRange(row,12).getValue();
let user = Session.getActiveUser().getEmail();
let cellLocation = sheet.getActiveCell().getA1Notation();
let url = "MyURL"
if(col == 11 && sheet != "Data") {
MailApp.sendEmail(
'MyEmail',
address + ' has been updated🔥',
'This an automated notice that ' + fieldsuper + ' has updated ' + address + ' (' + ordernumber + ') with the notes ' + notes + ', the current status is ' + holdstatus + ' for the install date of ' + installdate + '. For more information, please check the carpet sheet directly at ' + url
);
};
}
`
Try it this way:
function autoemail(e) {
const sh = e.range.getSheet();
const excl = ["Sheet1", "Sheet2"];
const idx = excl.indexOf(sh.getName());
if (!~idx && e.range.columnStart == 11) {
const [address, ordernumber, installdate, jobtype, fieldsuper, , , , , , notes, holdstatus] = sh.getRange(e.range.rowStart, 1, 1, 12).getValues();
let user = Session.getActiveUser().getEmail();
let cellLocation = e.range.getA1Notation();
let url = "MyURL"
MailApp.sendEmail('MyEmail', address + ' has been updated🔥','This an automated notice that ' + fieldsuper + ' has updated ' + address + ' (' + ordernumber + ') with the notes ' + notes + ', the current status is ' + holdstatus + ' for the install date of ' + installdate + '. For more information, please check the carpet sheet directly at ' + url
);
};
}
what I am trying to do is to check to see if the date in column RTC is 90 days past the date in column "Initial Date Seen by Dr." I have already done that using Sheet's formulas. Works perfectly. But then I want to compare this date in column L to see if today date (The computer's date) matches this date in column L. If so, I want to send an email.
So far everything works. But here's one little problem. As you can see in the image below, the first record shows that the date in column RTC is 7/21/20 which doesn't match today's date 5/26/20 but I still receive email for this record saying follow up with the patient.
Is there any fix for this?
function ifItsBeen90Days()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
sheet = ss.getSheetByName("PAOS");
range = sheet.getDataRange();
values = range.getValues();
var lR = sheet.getLastRow();
var dateinfo = sheet.getRange('L3:L').offset(0, 0, lR, 1).getValues();
var today = new Date();
var y0 = today.getFullYear();
var m0 = today.getMonth() + 1;
var d0 = today.getDate();
for (var i=0; i<dateinfo.length; i++){
x = Date.parse(dateinfo[i]);
var date = new Date(x);
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
if (y0 === y && m0 === m && d0 === d) {
SendItIf90daysPast();
} else {
Logger.log("error:" + i) // difference date
};
};
}
function SendItIf90daysPast(){
const ss = SpreadsheetApp.getActiveSheet();
const dataRange = ss.getDataRange();
const headers = 2;
const dataValues=ss.getRange(3,1,ss.getLastRow()-2,ss.getLastColumn()).getValues();
dataValues.forEach(function(row){
if(row[11] !== "") {
let message = " It's been 90 days since your last visit with the following Patient. " + '\n' +
" Can you please do a follow visit with this Patient? " + '\n' + '\n' +
" Thank you for your time and effort. " + '\n' +
" _______________________________________________________________ " + '\n' +
" Patient#: " + row[0] + '\n' +
" Patient Name: " + row[1] + '\n' +
" P-Code: " + row[2] + '\n' +
" PAO/INF: " + row[3] + '\n' +
" Score 1: " + row[4] + '\n' +
" Score 1 Date: " + new Date(row[5]).toLocaleDateString("en-US") + '\n' +
" Score 2: " + row[6] + '\n' +
" Score 2 Date: " + new Date(row[7]).toLocaleDateString("en-US") + '\n' +
" Tx Plan Entry Date: " + new Date(row[8]).toLocaleDateString("en-US") + '\n' +
" First Date: " + new Date(row[9]).toLocaleDateString("en-US") + '\n' +
" Initial Date Seen by DR: " + new Date(row[10]).toLocaleDateString("en-US") + '\n' +
" RTC: " + new Date(row[11]).toLocaleDateString("en-US") + '\n' +
" Notes: " + row[13];
let email = row[12];
let subject = 'Encrypt: Please Follow Up With Patient:' + " " + row[1] + " Patient #: " + row[0];
MailApp.sendEmail(email, subject, message);
Logger.log(`${subject}: ${message} sent to ${email}`);
}
});
}
If you want to check if a date is the same in one column as it is in another, or even if a particular date is 90 days after / before another date, I recommend creating additional columns (which can be hidden) for this purpose. Why? Well, once you grab the date, you (can) actually get the day before, see here for more infos which is an annoying issue.
So your for loop would then create the condition like this:
// lets assume column 15 contains your date check logic
function ifItsBeen90Days(){
const rows = SpreadsheetApp.getActive().getSheetByName("PAOS").getDataRange().getValues();
rows.forEach( (row, index) => {
const doesConditionApply = row[16]; // 15th col, is 16th index
// skip if the value is not what you are looking for
if( doesConditionApply != true ){
return
}
SendItIf90daysPast()
});
}
function ifItsBeen90Days() {
const ss=SpreadsheetApp.getActive();
const shsr=3;
const sh=ss.getSheetByName("PAOS");
const rg=sh.getDataRange();
const v=sh.getRange(shsr,11,sh.getlastr()-shsr+1,1).getValues();
const dt=new Date();
const today=new Date(dt.getFullYear(),dt.getMonth(),dt.getDate());
const t90v=new Date(dt.getFullYear(),dt.getMonth(),dt.getDate()-90).getTime();
const t91v=new Date(dt.getFullYear(),dt.getMonth(),dt.getDate()-91).getTime();
const tv=today.getTime();
v.forEach(function(r,i){
var d=new Date(r[0]);
var dv=new Date(d.getFullYear(),d.getMonth(),d.getDate()).valueOf();
var diff=dv-tv;
if(diff>=t90v && diff<t91v){
//it has been 90 days
}
});
}
I want my function to activate on specific sheet only. But I really do not know how to write. I have like 14 sheets. And anytime one of the sheets' values are changed. It automatically sends out an email which I do not want. I want my function to send email only based on the sheet I want. (I have add the trigger manually on my current project trigger).
function CheckbudgetAUD() {
for(var i=2;i<1000; i++){
var num1 = i;
var r = 4;
var department = "AUD";
var transactionIDRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,14);
var transactionID = transactionIDRange.getValue();
var monthRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,12);
var month = monthRange.getValue() ;
var costdescriptionRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,3);
var costdescription = costdescriptionRange.getValue();
var costRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,4);
var cost = costRange.getValue();
var actualbudgetRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,4);
var actualbudget = actualbudgetRange.getValue();
var ApprovalRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,18);
var Approval = ApprovalRange.getValue();
var purposeRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,7);
var purpose = purposeRange.getValue();
var timeRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,1);
var time = timeRange.getValue();
var CEOsapprovalRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,19);
var CEOsapproval = CEOsapprovalRange.getValue();
var addinformationRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,5);
var addi = addinformationRange.getValue();
var thisisdoneRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,30);
var thisisdone = thisisdoneRange.getValue();
var BlankRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,2);
var Blank = BlankRange.getValue();
//Emails Range
var email1Range = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Forecasted budget").getRange("F18");
var email1address = email1Range.getValue();
var email2Range = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Forecasted budget").getRange("F21");
var email2address = email2Range.getValue();
var email3Range = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(department).getRange(num1,6);
var email3address = email3Range.getValue();
// Messages Range
var message1 = "Your request has been " + Approval + "d." + "\n" + "\n" + "Transaction ID: " + transactionID;
var message = "For the " + month + ", " + department + "'s " + costdescription + ' budget exceeded the limit'+ '\n'+ '\n'+ "CURRENT BUDGET APPLICATION INFORMATION" + "\n" + "COST: "+ cost + '\n' + "Transaction ID: "+ transactionID +'\n' + "Cost item: " + costdescription + "\n" + "Purpose: "+ purpose + "\n" + "Department Name: " + department + "\n" + "Timestamp: " + time + "\n" + "additional information: " + addi+ "\n" + 'Click the link below to approve'+ '\n' + 'https://docs.google.com/forms/d/e/1FAIpQLSduX3ol31Ddy3klEpynlO33wprEivAr-e9BL7fZ6Th-JQgjZA/viewform';
var subject = 'Exceeded the budget limit for current month';
var subject1 = 'Form Approval/Decline';
if ( Blank !== "" && thisisdone == "Apple"){
MailApp.sendEmail(email3address, subject1, message1);
}
//Over budget email
if ( Approval == "Decline" && thisisdone == "Apple"){
if ( cost < 200000 ) {
MailApp.sendEmail(email1address, subject, message);}
else if ( cost >= 200000 ) {
MailApp.sendEmail(email2address, subject, message);
}
}
}
}
I am also basically sending out email to 3 different parties at the same time in one function. Just FYI.
You might like to consider this sort of approach. You will find it to run much faster. Although there may be some corrections you will want to make. I noticed some duplication in the range assignments which are reflected in my assignments as well. Keep in mind that column number start at one and array indices start at zero.
function CheckbudgetAUD() {
var department = "AUD";
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName(department)
var fsh=ss.getSheetByName("Forcasted budget");
var vA=sh.getRange(2,1,sh.getLastRow()-1,sh.getLastColumn()).getValues();
for(var i=0;i<vA.length; i++){
var transactionID = vA[i][13];
var month = vA[i][11];
var costdescription = vA[i][2];
var cost = vA[i][3];
var actualbudget=vA[i][3];
var Approval=vA[i][17];
var purpose=vA[i][6];
var time=vA[i][0];
var CEOsapproval=vA[i][18];
var addi=vA[i][4];
var thisisdone=vA[i][29];
var Blank=vA[i][1];
var email1address = fsh.getRange("F18").getValue();
var email2address = fsh.getRange("F21").getValue();
var email3address = vA[i][5];
var message1 = "Your request has been " + Approval + "d." + "\n" + "\n" + "Transaction ID: " + transactionID;
var message = "For the " + month + ", " + department + "'s " + costdescription + ' budget exceeded the limit'+ '\n'+ '\n'+ "CURRENT BUDGET APPLICATION INFORMATION" + "\n" + "COST: "+ cost + '\n' + "Transaction ID: "+ transactionID +'\n' + "Cost item: " + costdescription + "\n" + "Purpose: "+ purpose + "\n" + "Department Name: " + department + "\n" + "Timestamp: " + time + "\n" + "additional information: " + addi+ "\n" + 'Click the link below to approve'+ '\n' + 'https://docs.google.com/forms/d/e/1FAIpQLSduX3ol31Ddy3klEpynlO33wprEivAr-e9BL7fZ6Th-JQgjZA/viewform';
var subject = 'Exceeded the budget limit for current month';
var subject1 = 'Form Approval/Decline';
if (Blank!=="" && thisisdone=="Apple"){
MailApp.sendEmail(email3address, subject1, message1);
}
if (Approval=="Decline" && thisisdone=="Apple"){
if (cost<200000) {
MailApp.sendEmail(email1address, subject, message);
}else if( cost >= 200000 ) {
MailApp.sendEmail(email2address, subject, message);
}
}
}
}
If you're attempting to run something like this from onEdit() then you will want to limit which sheets that you want it to run on. For example consider the event object to be represented by an e then
function onEdit(e) {
var sh=e.range.getSheet();
if(sh.getName()!='AUD')return;
This will limit the script to running only for sheet AUD.
I have a code I use to send email reminders based on dates in a spreadsheet. Most of the sheets I use it for are simple and under 100 lines of data. In the past I have used individual variables for each cell but I am looking for a way to find all instances of a value in a column (D), in this case, it is a city code ("SEA"), and return the row number, which I then want to take and use in a var to make it act like a vlookup.
ex: var empname = ss.getRange("A"+ rownumber).getValue();
Which should return column A of whichever row has "SEA" in it.
The challenge then is to be able to go down the column and do the same for each row that has "SEA" in it.
This is a one-line version of what I have done in the past.
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var ss = spreadsheet.getSheetByName("Active");
var empnum = ss.getRange("A8").getValue();
var empfirstname = ss.getRange("C8").getValue();
var emplastname = ss.getRange("B8").getValue();
var emplocation = ss.getRange("D8").getValue();
var test = ss.getRange("H8").getValue();
if (test === -1 && emplocation === "SEA"){
var message = empnum + " " + empfirstname + ' ' + emplastname + ' is past due for testing.' + '\n'
} else if (test === 0 && emplocation === "SEA"){
var message = empnum + " " + empfirstname + ' ' + emplastname + ' will be due for testing soon.' + '\n'
} else if (test === 1) {
var message = "";
}
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Email Group").getRange("A1");
var emailAddress = emailRange.getValues();
var subject = 'Test reminder';
MailApp.sendEmail(emailAddress, subject, '**This is an automated message**\n\n' + 'Test reminder:\n\n' + message + '\n\n**This is an automated message**\n');
}
The H column will present a -1, 0 or 1 depending on the date in the G column to determine if someone is due to take a test or not. I then want to send an email with the Employee Number, First Name and Last Name for each employee at the SEA branch. This has worked for me in the past but I have 230+ lines of employees and don't want to create that many variables. My solution is to get the row number of each row with a "SEA" location and use that as a variable in a getRange call. Not sure exactly how that would work, or if it even would. If there is a better solution, I am amenable to that.
Requirement:
Send an email when a row contains "SEA" and column H matches -1 or 0.
Solution:
function findAndSendMail() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Active');
//find all occurrences of "SEA" and push range to array
var search = "SEA";
var ranges = ss.createTextFinder(search).findAll();
var message = ''; //pre-define email body
//loop through each range
for (i = 0; i < ranges.length; i++) {
var row = ranges[i].getRow();
var lastCol = ss.getLastColumn();
var values = ss.getRange(row, 1, 1, lastCol).getValues(); //get all values for the row
var empnum = values[0][0]; //column A
var empfirstname = values[0][2]; //column C
var emplastname = values[0][1]; //column B
var emplocation = values[0][3]; //column D
var test = values[0][7]; //column H
if (test === -1) {
message+=Utilities.formatString(empnum + " " + empfirstname + ' ' + emplastname + ' is past due for testing.\n');
} else if (test === 0) {
message+=Utilities.formatString(empnum + " " + empfirstname + ' ' + emplastname + ' will be due for testing soon.\n');
}
}
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Email Group").getRange("A1");
var emailAddress = emailRange.getValues();
var subject = 'Test reminder';
if (message) { //make sure message is not blank
MailApp.sendEmail(emailAddress, subject, '**This is an automated message**\n\n' + 'Test reminder:\n\n' + message + '\n\n**This is an automated message**\n');
}
}
Explanation:
Okay, so I've made quite a few changes to your original script, if there's anything I've missed please let me know, I'm happy to explain it.
First of all, I've changed the script so that we're using textFinder, this is so that we can search through your sheet to find your desired pattern "SEA". This then pushes all of the ranges to an array that we are looping through in the for loop.
When looping through the ranges, we can grab all of the data in the row (e.g. values[0][0] is the data in column A). This is then pushed to var message to build the email body in the same format you specified in your question.
I've tried to keep the variable names alike to the ones in your original script to make it easier to understand which parts of the script are essentially the same as your original. Also there are comments throughout the script that should help you understand what it's doing at each point.
References:
textFinder Documentation
Update:
To scan only a certain column, try the code below instead. I've defined var range separately so that we can use textFinder on that range rather than the whole sheet.
function findAndSendMail() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Active');
//define range to search
var lastRow = ss.getLastRow();
var range = ss.getRange(1, 4, lastRow); //range for column D
//find all occurrences of "SEA" in column D and push range to array
var search = "SEA"
var ranges = range.createTextFinder(search).findAll();
var message = '';
//loop through each range
for (i = 0; i < ranges.length; i++) {
var row = ranges[i].getRow();
var lastCol = ss.getLastColumn();
var values = ss.getRange(row, 1, 1, lastCol).getValues(); //get all values for the row
var empnum = values[0][0]; //column A
var empfirstname = values[0][2]; //column C
var emplastname = values[0][1]; //column B
var emplocation = values[0][3]; //column D
var test = values[0][7]; //column H
if (test === -1) {
message+=Utilities.formatString(empnum + " " + empfirstname + ' ' + emplastname + ' is past due for testing.\n');
} else if (test === 0) {
message+=Utilities.formatString(empnum + " " + empfirstname + ' ' + emplastname + ' will be due for testing soon.\n');
}
}
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Email Group").getRange("A1");
var emailAddress = emailRange.getValues();
var subject = 'Test reminder';
if (message) {
MailApp.sendEmail(emailAddress, subject, '**This is an automated message**\n\n' + 'Test reminder:\n\n' + message + '\n\n**This is an automated message**\n');
}
}
I'm trying to invoke the following:
var range5 = SpreadsheetApp.getActiveSheet().getRange(range1:range3);
where range1 = "C590" (string value) and range3 = "O594"
(string value) (found previously in the script)
But I get the error:
Missing ) after argument list
for the range5 line. Is there a way to pass the two strings as the range?
The questioner has a problem with this line of code
var range5 = SpreadsheetApp.getActiveSheet().getRange(range1:range3);
This line of code would have worked:
var range5 = SpreadsheetApp.getActiveSheet().getRange(range1+":"+range3);
The main thing here is how the variables are added/assigned to the command, and how the separator is added between the variables.
There are at least four variations for getRange but the most basic is "getRange ('cell/range address')". As shown above, it IS possible to join the variables and a separator to create a valid range.
But there are other options. In this scenario, the most obvious is getRange(row, column, numRows, numColumns). This expects integer parameters but getRow and getColumn can be used to break down each of the strings.
The code below is an example of managing the ranges as strings.
Each string is used separately to create the parameters of the specific range.
Step#1 - The string for range1 is used in getRange. This permits...
Step#2 and #3 - get the row and column integers for the range.
Step#4 - Repeat for range3
Step#5 - Now we can get range5 using "getRange (row, column, num rows, num columns)". The values for this are supplied/calculated from steps#1 thru 4.
function so_52759685() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range1 = "C590";
var rangeone = sheet.getRange(range1);
var rangeonerow = rangeone.getRow();
var rangeonecolumn = rangeone.getColumn();
Logger.log("RANGE1: " + range1 + " - row = " + rangeonerow + ", and the column number = " + rangeonecolumn); // DEBUG
var range3 = "O594";
var rangethree = sheet.getRange(range3);
var rangethreerow = rangethree.getRow();
var rangethreecolumn = rangethree.getColumn();
Logger.log("RANGE3: " + range3 + " - row = " + rangethreerow + ", and the column number is " + rangethreecolumn); //DEBUG
var range5 = sheet.getRange(rangeonerow, rangeonecolumn, rangethreerow - rangeonerow + 1, rangethreecolumn - rangeonecolumn + 1)
var range5Rows = range5.getNumRows();
var range5Columns = range5.getNumColumns();
Logger.log("RANGE5: " + range5.getA1Notation() + " - Number of rows = " + range5Rows + ", and number of columns" + range5Columns);
}
Alternatively, one might use a named range.
The same process applies except that:
1 - range1 and range3 are Named Ranges, assigned to C590 and O594 respectively.
2 - Instead of declaring the string literals, we use GetNamedRange.
function so_5275968502() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var rangeone = ss.getRangeByName("range1");
Logger.log("range one is " + ss.getRangeByName("range1").getA1Notation()); //DEBUG
var rangeonerow = rangeone.getRow();
var rangeonecolumn = rangeone.getColumn();
Logger.log("RANGE1: " + rangeone.getA1Notation() + " - row = " + rangeonerow + ", and the column number = " + rangeonecolumn); //DEBUG
var rangethree = ss.getRangeByName("range3");
Logger.log("range three is " + ss.getRangeByName("range3").getA1Notation()); //DEBUG
var rangethreerow = rangethree.getRow();
var rangethreecolumn = rangethree.getColumn();
Logger.log("RANGE3: " + rangethree.getA1Notation() + " - row = " + rangethreerow + ", and the column number is " + rangethreecolumn); //DEBUG
var range5 = sheet.getRange(rangeonerow, rangeonecolumn, rangethreerow - rangeonerow + 1, rangethreecolumn - rangeonecolumn + 1)
var range5Rows = range5.getNumRows();
var range5Columns = range5.getNumColumns();
Logger.log("RANGE5: " + range5.getA1Notation() + " - Number of rows = " + range5Rows + ", and number of columns" + range5Columns); //DEBUG
}