There are alternatives. Firstly a word of warning. I program specifically for 365; I only work with defined names, never direct cell references; I only work with array formulas, never scalars. That makes my formulas look pretty unfamiliar to most!
The first uses XLOOKUP which has the 'not found' condition built in. The second does not perform lookups at all but, instead, relies upon the pattern of requiring values to be distributed to every 5th cell.