Finds the next available blank row in a worksheet. This macro allows you to get the blank at the very end of your data (not between it).
(function () { // Getting the active sheet var activeSheet = Api.ActiveSheet; // Minimum row index var indexRowMin = 0; // Maximum row index var indexRowMax = 1048576; // Column 'A' var indexCol = 0; // Row index for empty cell search var indexRow = indexRowMax; for (; indexRow >= indexRowMin; --indexRow) { // Getting the cell var range = activeSheet.GetRangeByNumber(indexRow, indexCol); // Checking the value if (range.GetValue() && indexRow !== indexRowMax) { range = activeSheet.GetRangeByNumber(indexRow + 1, indexCol); range.Select(); break; } } })();
Methods used: GetActiveSheet, GetRangeByNumber, Select
This VBA macro was used as a base.
Sub example() Range("A" & Rows.Count).End(xlUp).Offset(1).Select End Sub