=MATCH(TRUE,INDEX(ISBLANK(INDIRECT("R[1]C:R1048576C",0)),0,0),0)+ROW()
This formula above returns the row number of the first blank cell in the current column and below the current row, but it does not need to be entered in row 1 of the worksheet.
It replaces the A:A
target range with a range that starts in the next row and continues to the end of the sheet and then adds the current row number to the result to add the skipped rows back in. This avoids the circular reference since it starts on the next row.
Using the INDIRECT(ref_text, [a1])
function with the second argument set to FALSE
or 0
allows you to pass ref_text
in R1C1 notation (eg. B5
as R5C2
).
The R1C1 notation also has a lesser known syntax for describing a location as an offset from the current position. If the number following the R or C is enclosed in square braces then it is treated as a +/- offset from the current cell or zero offset if omitted (eg. "R[-1]C[-1]"
in cell B5
returns A4
and "RC"
in B5
returns itself B5
).
The R1C1 location of R[1]C:R1048576C
from the formula defines a range starting at the current cell with a RC offset of 1,0 and ending at fixed row 1048576 with a 0 column offset from the current cell. When placed in cell C3
it will be equivalent to C4:C1048576
and in A1
is equivalent to A2:A1048576
. If you needed to dynamically set the max row number, you use INDIRECT("R[1]C:R"&ROWS(A:Z)&"C",0)
but since current version Excel has a row limit of 1,048,576 it makes sense to just set it.