Reputation: 77
I have a sheet where data is updated daily.
however, the last integer often ends in between row 131 to 133.
how do I run a query function to display the last integer in row 1 column C?
I cannot do a simple =A131
on C1 because it can be on A133 the next day.
images: https://i.sstatic.net/eJAAF.jpg
Upvotes: 4
Views: 12231
Reputation: 7949
This is a simplified version of my original code.
The value of the last integer and the row number are output for user information.
The code copes with dates, text, pseudo-value text (37*2), and decimals.
function so5754079102() {
var ss = SpreadsheetApp.getActiveSpreadsheet()
var sheetname = "Sheet1";
var sheet = ss.getSheetByName(sheetname);
var Avals = ss.getRange("A1:A").getValues();
var Alast = Avals.filter(String).length;
Logger.log("Last row = "+Alast);
var data = sheet.getRange(1,1,Alast,1).getValues();
for (var i = Alast-1;i>=0;i--){
Logger.log("i = "+i+", data 1 ="+data[i][0]+", and parse data 1 = "+parseInt(data[i][0], 10));
if (data[i][0] === parseInt(data[i][0], 10)){
break;
}
}
sheet.getRange("D1").setValue(+(i+1));
sheet.getRange("D2").setValue(data[i][0]);
}
Screenshot
Upvotes: 0