GAS is trying to retrieve a specific column of the spreadsheet.
A particular column is the data in the row where "num" is the maximum value in the table below.
From this table, what code should I write to get the num, user, text value of row = 4 where num is the maximum value?
I look forward to your kind cooperation.
google-apps-script
In this case, how about the output of the built-in function as shown below?
= SORTN (A2:C, 1, 1,)
Or, if you need to use Google Apps Script from the Google-apps-script
tab, how about a sample script like the one below?
function sample(){
const sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); // Enter the sheet name.
const srcValues=sheet.getRange("A2:C" + sheet.getLastRow()) .getValues();
constres=srcValues.sort(a,b)=>a[0]<b[0]?1:-1)[0];
console.log(res);//<--- [4, 'C', 'Hello']
}
Both samples are sorted in descending order by column A to get the first row.
© 2024 OneMinuteCode. All rights reserved.