Explanation

This formula uses the COUNTA function to count values in a range.

COUNTA counts both numbers and text to so works well with mixed data.

The range B4:B8 contains 5 values, so COUNTA returns 5.

Excel formula: Last row in mixed data with blanks

COUNTA does not count empty cells.

Excel formula: Last row in numeric data

Excel formula: Last row in text data

Excel formula: Dynamic named range with OFFSET

Excel formula: Dynamic named range with INDEX

Excel COUNTA function