Counting the number of rows until a threshold is exceeded in an adjacent row.

klemmeri

New Member
Joined
Nov 19, 2017
Messages
1
Hi - I'd like to find a formula for column D in this spreadsheet. It uses the adjacent value in column C and then looks in column B to find a 'day' (row) where that value is exceeded. The returned value in column D is the number of days it took to reach the 5% over price value. For example, the 'D' column is the number of days it took for the price to exceed 5% of $99.74 (i.e. >$104.73). I used countif (which doesn’t work since it looks through the entire column). Can anyone help here? Thanks – klemmeri

PS new to this forum, so apologize in advance for any missteps.

A B C D
Date Stock price 5% daily return 'Number of days (in the future) until > 5% reached'
1/3 99.74 104.73
1/4 98.74 103.70
1/5 99.90 104.90
1/6 96.58 101.41
. . .
. . .
. . .
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Welcome to Mr Excel forum

Maybe something like this

[Table="class: grid"][tr][td="bgcolor: #DCE6F1"][/td][td="bgcolor: #DCE6F1"]
A
[/td][td="bgcolor: #DCE6F1"]
B
[/td][td="bgcolor: #DCE6F1"]
C
[/td][td="bgcolor: #DCE6F1"]
D
[/td][/tr]
[tr][td="bgcolor: #DCE6F1"]
1
[/td][td]
Date​
[/td][td]
Price​
[/td][td]
1.05*Price​
[/td][td]
Days​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
2
[/td][td]
1/3​
[/td][td]
99,74​
[/td][td]
104,727​
[/td][td]
4​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
3
[/td][td]
1/4​
[/td][td]
98,74​
[/td][td]
103,677​
[/td][td]
3​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
4
[/td][td]
1/5​
[/td][td]
99,9​
[/td][td]
104,895​
[/td][td]
Not found​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
5
[/td][td]
1/6​
[/td][td]
96,58​
[/td][td]
101,409​
[/td][td]
1​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
6
[/td][td]
1/7​
[/td][td]
104,74​
[/td][td]
109,977​
[/td][td]
Not found​
[/td][/tr]
[/table]


Formula in D2 copied down
=IFERROR(MATCH(1,INDEX(--(B3:B$1000>C2),),0),"Not found")

Hope this helps

M.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top