79400564

Date: 2025-01-30 16:33:07
Score: 0.5
Natty:
Report link

With some help from @Rory (many thanks), I think I can now explain this behaviour.

The key things to understand are:

This explains why, in this unique case of a 2D reference with an omitted column_num, a #REF! error is returned, whereas the equivalent call on a literal array (or an in-memory cell range) succeeds because the "array form" supports this.

Examples:

=INDEX(A1:B2, 0) : fails (reference form; col_num is required for a 2D reference)

=INDEX(A1:B2, 0, ) : succeeds (reference form; the comma means that col_num is present, even though 'missing')

=INDEX({1, 2; 3, 4}, 0) : succeeds (array form; col_num is optional for a 2D array)

=INDEX(INDEX(A1:B2, 0, 0), 0) : fails (a _reference_ is passed to the outer INDEX() call)

=INDEX(SQRT(INDEX(A1:B2, 0, 0)), 0) : succeeds (an _array_ is passed to the outer INDEX() call)

This last example is the "range of cells" case: the inner INDEX() function returns a reference, which is processed by the SQRT() function, returning an array ("range of cells"), which then calls the "array form" of the outer INDEX() function.

I still do not understand why this difference is necessary; I can see no reason why the "reference form" should not behave identically to the array form in this regard. Presumably there is a reason, which I would love to hear if anyone knows it!

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Blacklisted phrase (1): anyone knows
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Rory
  • User mentioned (0): @Rory
  • Self-answer (0.5):
  • High reputation (-1):
Posted by: Neil T