How many cells does it take to exceed X, and stop counting

Diamond Dave

New Member
Joined
Jan 9, 2010
Messages
7
Ladies and gentlemen,
I am trying to compare a value ( say C80 ) and figure out how many cells it takes to exceed a value ( say -2 ) in a column ( say E79:E2 ) but then actually stopping the count after that first cell count has been triggered.
I'm in a bind - any help would be highly appreicated.
Dave
 
Dave! Sorry for dropping the ball on this one.

See if this does what you want (formula pasted down):

Excel Workbook
ABCDEF
1DateHighCloseAnswer
26-May-0938.7737.76#N/A
37-May-0940.1439.581
48-May-0941.5741.32
511-May-0941.0140.553
612-May-0941.4840.674
713-May-0940.7839.945
814-May-0940.36
Sheet1
Excel 2003
Cell Formulas
RangeFormula
F2=ROW(C2)-LOOKUP(2,1/($E1:E$2<=C2-2),ROW($E1:E$2))
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
:) I really appreciate your help with this. I will definately try that out. You would understand where I tried to hit up multiple sources to solve this, and a guy that I work with was able to work it in VB. I am still going to try out your formula since the spreadsheet would not have to call out for a VB macro. Just in case though, here is what he came up with.

Function greaterBy2GoingUp(MatchValue As Variant, SearchRange As Range)
Dim i As Long, test As Single
For i = SearchRange.Cells.Count To 1 Step -1
test = MatchValue - 2
If SearchRange.Cells(i) < test Then
greaterBy2GoingUp = 1 + SearchRange.Cells.Count - i
Exit Function
End If
Next
greaterBy2GoingUp = "#N/A"
End Function
Function greaterBy2GoingDown(MatchValue As Variant, SearchRange As Range)
Dim i As Long, test As Single
For i = 1 To SearchRange.Cells.Count Step 1
test = MatchValue + 2
If SearchRange.Cells(i) > test Then
greaterBy2GoingDown = i
Exit Function
End If
Next
greaterBy2GoingDown = "#N/A"
End Function

Again thank for your help and I will let you know if the formula works!
Dave
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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