A Challenge: Detection of first and Last +ve number in a range
Chris Gorham wrote...
....
I can get part of the "forecast" function to work using "indirect" to
reference the beginning and end of the data sequence - I can therefore
control the range that "forecast" covers. It is now simply a matter of
detecting the beginning and end of the sequence.
....
If you have a variable number of positive values in, say, B3:IV3, the
index of the first one would be given by the array formula
=MATCH(TRUE,B3:IV30,0)
and the index of the last one would be given by
=MATCH(2,1/(B3:IV30))
So the dynamic range from the first to the last could be given by
INDEX(B3:IV3,MATCH(TRUE,B3:IV30,0)):INDEX(B3:IV3, MATCH(2,1/(B3:IV30)))
which would need array entry in formulas.
|