The problem can also be solved in Excel itself without Visual Basic.
Let us denote by with column or row range that we are analyzing. You can actually give this name to a range or in the following formulas in place of with enter the addresses of the range.
All the following formulas are array formulas , so you must approve them with Ctrl + Shift + Enter .
To read first value in a column or row range, you can use the formula:
= INDEX (z, MATCH (FALSE, ISBLANK (z), 0))
As an alternative to a column range, you can use one of the formulas:
= OFFSET (z, MATCH (FALSE, ISBLANK (z), 0) - 1,0)
= INDEX (z, MIN (IF (ISBLANK (z), "", ROW (z))) - ROW (z) +1)
The last formula can be simplified if the range starts with the first line:
= INDEX (z, MIN (IF (ISBLANK (z), "", ROW (z))))
Similarly, in the case of a row range, you can use the following formulas:
= OFFSET (z; 0, MATCH (FALSE, ISBLANK (z), 0) - 1)
= INDEX (z; MIN (IF (ISBLANK (z); "", COLUMN (z))) - COLUMN (z) +1)
The last formula can be simplified if the range starts with the first column:
= INDEX (z, MIN (IF (ISBLANK (z), "", COLUMN (z))))
To read last value in a column range, you can use the formula:
= INDEX (z, MAX (IF (ISBLANK (z), 0, ROW (z))) - ROW (z) +1)
As before, the formula can be simplified if the range starts with the first line:
= INDEX (z, MAX (IF (ISBLANK (z), 0, ROW (z))))
In the case of a row range, the analogous formula is:
= INDEX (z, MAX (IF (ISBLANK (z), 0, COLUMN (z))) - COLUMN (z) +1)
If the range starts with the first column, the formula might be shorter:
= INDEX (z, MAX (IF (ISBLANK (z), 0, COLUMN (z))))