Consecutive amounts greater than 2500

rodgo

New Member
Joined
Jun 5, 2003
Messages
40
I have a row of numbers. I would like to get the number of consecutive times the number is above 2500. For example, A1 through Z1 contain numbers. If C1 through E1 contain numbers above 2500 I want the number returned to be 3. Now, if there are several times that this happens between A1 and Z1, then i want the 'longest streak'.

Please tell me you all understand!?!?!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

A2: =IF(A1>2500,1,0)
B2: =IF(B1>2500,A2+1,0)
copy from B2 to Z2
A3: =MAX(A2:Z2)

Another way would be to build your own function. Something like

Code:
Function MyFunc(ra As Range, tester)
  final = 0
  interim = 0
  For Each ce In ra
    If ce > tester Then
      interim = interim + 1
    Else
      If interim > final Then
        final = interim
      End If
      interim = 0
    End If
  Next ce
  MyFunc = final
End Function

With your data in the range A1:Z1 use the formula in the form
=myfunc(A1:Z1,2500)

HTH

Tony
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,705
Here's another way...

=MAX(FREQUENCY(IF(A1:Z1>2500,COLUMN(A1:Z1)),IF(A1:Z1<=2500,COLUMN(A1:Z1))))

...confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!
 

Forum statistics

Threads
1,136,990
Messages
5,678,989
Members
419,797
Latest member
ikethegenius

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
Top