Error 502 produced inconsistently with Randbetween/Choose nested function

Mojave 10.14.6, LO

I’m using a mixture of the Randbetween/Choose functions in an attempt to generate two numbers in two cells between 1 and 8, the first being generated with RANDBETWEEN(1,8) (although is is currently a validated list with numbers between 1 and 8) and the second being any number except the first e.g. if the first number is 1, the second number can be any number except 1 i.e. numbers 2-8.

I’ve noticed upon testing this formula that certain numbers in the first cell elicit a “error 502” result in the second, but only intermittently; other times when the same numbers appear in the first cell a number, rather than error 502, is generated in the second cell.
Just wondering what this is all about, and how I can avoid an “error 502” generation. I haven’t really used Choose before so any assistance is greatly appreciated.

numbers sometimes triggering error 502.ods

Of course it will give you an Err:502 when your formula


gets e.g. 2 in A2, and tries to calculate the sub-formula


and RANDBETWEEN happens to return 8 - so CHOOSE tries to find the 8th value in the list 1;3;4;5;6;7;8 having only 7 elements.

By the way, all that formula could be replaced by


Maybe the only really useful application of CURRENT().