So I should start by saying I\'m new at Javascript/programming. I understand a good amount of it but don\'t really know what I\'m doing when it comes to actually writing it.
The referenced question provides scripts with a reference to the first empty row in a spreadsheet. (...although some of those solutions find the first empty cell in column A, which isn't necessarily an empty row. But I digress.)
In a spreadsheet-attached script with access to the User Interface, you can affect the active view of the spreadsheet with several functions:
Using whatever technique you wish to identify the "empty row" in the active spreadsheet, this function will move the selection to it, using .setActiveSelection()
:
/**
* Place the current user's cursor into the first cell of the first empty row.
*/
function selectFirstEmptyRow() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
sheet.setActiveSelection(sheet.getRange("A"+getFirstEmptyRowWholeRow()))
}
The getFirstEmptyRowWholeRow()
function, if you're curious:
/**
* Mogsdad's "whole row" checker.
*/
function getFirstEmptyRowWholeRow() {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getDataRange();
var values = range.getValues();
var row = 0;
for (var row=0; row<values.length; row++) {
if (!values[row].join("")) break;
}
return (row+1);
}