I'm facing an issue with this script. My goal is to search for today's date, match it, and return the column number (which is already working!). Now, I need a script that can do the same but with row numbers. The current script works fine if there is only one table on the sheet, however, since I have multiple tables, using values.length -1 will return the last row from the entire sheet. Additionally, each table may not have fixed row numbers, so the solution needs to be dynamic.
Here is the script I have developed so far:
function getTodaysTotal() {
function toDateFormat(date) {
try {return date.setHours(0,0,0,0);}
catch(e) {return;}
}
var values = SpreadsheetApp
.openById("id")
.getSheetByName("Q3 - W27 - 39")
.getDataRange()
.getValues();
var today = toDateFormat(new Date());
var todaysColumn = values[5].map(toDateFormat).map(Number).indexOf(+today);
var output = values[values.length - 1][todaysColumn];
var emailDate = Utilities.formatDate(new Date(today),"GMT+1", "dd/MM/yyyy");
Attached below is a screenshot of my table:
I hope this clarifies the situation. I already have the column number, now I just need to find the row number that contains "Total".
Thank you!
Regards,