Thanks for your responses Lionelhill and Skip!
Lionelhill’s solution works but I want to select the value in the first column that adjacent to the first positive value in the second column. I am trying to create an automated payback period table which calculates the payback period. In the example below, I get the years (number of the left side of the decimal by using countif) and the numerator (on the right side of the decimal by using lookup) but I can’t get denominator. Lionelhill’s solution selects $7000 instead of $5000.
Payback period is calculated by the formula: number of years (in column A) that there was a negative cash flow Plus (last negative value in column C divided by value in column B adjacent to the first positive value in column C). The answer should by 20.20 in the case below.
Column A Column B Column C
0 -$101,000.00
1 $5,000.00 -$96,000.00
2 $2,000.00 -$94,000.00
3 $6,000.00 -$88,000.00
4 $7,000.00 -$81,000.00
5 $5,000.00 -$76,000.00
6 $2,000.00 -$74,000.00
7 $6,000.00 -$68,000.00
8 $7,000.00 -$61,000.00
9 $5,000.00 -$56,000.00
10 $2,000.00 -$54,000.00
11 $6,000.00 -$48,000.00
12 $7,000.00 -$41,000.00
13 $5,000.00 -$36,000.00
14 $2,000.00 -$34,000.00
15 $6,000.00 -$28,000.00
16 $7,000.00 -$21,000.00
17 $5,000.00 -$16,000.00
18 $2,000.00 -$14,000.00
19 $6,000.00 -$8,000.00
20 $7,000.00 -$1,000.00
21 $5,000.00 $4,000.00
22 $2,000.00 $6,000.00
23 $6,000.00 $12,000.00
24 $7,000.00 $19,000.00
25 $5,000.00 $24,000.00
26 $2,000.00 $26,000.00
27 $6,000.00 $32,000.00
28 $7,000.00 $39,000.00
29 $5,000.00 $44,000.00
30 $2,000.00 $46,000.00
31 $6,000.00 $52,000.00
32 $7,000.00 $59,000.00
33 $5,000.00 $64,000.00
34 $2,000.00 $66,000.00
35 $6,000.00 $72,000.00
36 $7,000.00 $79,000.00
37 $3,000.00 $82,000.00
20 =COUNTIF(C3:C39,"<0")
-1000 =(LOOKUP(0, C3:C39))
5000 =?????
Payback Period = 20 + -(-1000/5000)