gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
apps script select sheet and get last data row. and i want to activate last+1 row
- User
apps script select sheet and get last data row. and i want to activate last+1 row
- Assistant
To select a sheet and get the last data row using Google Apps Script, you can use the following code:
javascriptfunction selectSheetAndLastRow() { // Add your sheet name here var sheetName = "Sheet1"; // Select the sheet var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName); // Get the last row with data var lastRow = sheet.getLastRow(); // Get the last+1 row var newRow = lastRow + 1; // Activate the last + 1 row sheet.getRange(newRow, 1).activate(); }Make sure to replace "Sheet1" with the name of the sheet you want to select. The code will get the last row with data in the selected sheet and then activate the next row.
To run this code, you can create a new script in your Google Sheets by going to
Extensions->Apps Script. Paste the code into the script editor, save it, and then run theselectSheetAndLastRowfunction.