Your programs don't show what you intend to do if the function argument x is not exactly in the list of nominal diameters.
The programs (with Terry's fix applied) will return just the last value of j in this case (15).
If, as I assume, that's not intended, you could simply place the return value you want to see in case of an invalid x in the last program line, like:

To achieve what you obviously intend to do (take the nominal diameter ND, lookup the corresponding outer diameter OD and use it to calculate the cross-sectional area) could more easily be done using the "lookup" function:

To avoid the error in case x is not in the list you could add your own return value in case lookup fails:

I think that returning the index j as well was done just for debugging. But in case you really need that index you could use the "match" function (see attached sheet).
You may also just use the next larger value in ND in case x is not found in that list

Similarly you could also decide to use the next smaller value or the nearest value (see attached sheet).
And of course a further option would be to use linear interpolation to deal with x-values not in the ND-list.

Prime 11 file attached
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

