Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Function negmax(xRng As Range) As Long
Dim xCell As Range Dim xSum As Long xSum = 0: negmax = 0 For Each xCell In xRng If xCell.Value < 0 Then xSum = xSum + xCell.Value Else xSum = 0 End If Debug.Print xSum, negmax If xSum < negmax Then negmax = xSum Next End Function You call the function using negmax(Range("A1:A14")) -- Cheers Nigel "Ev" wrote in message ... I have a list of returns like that listed below, I want to find out the greatest continuous run of negative returns, (i.e. -24-3 =-27, and is greater than -2-4-3-1-1-1=-12) so it would return a result of -27 6 7 2 0 -2 -4 -3 -1 -1 -1 7 -24 -3 2 4 A function would be the most preferable solution |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel, change column of negative numbers to positive numbers? | New Users to Excel | |||
Excel 2002 : Convert Positive Numbers to Negative Numbers ? | Excel Discussion (Misc queries) | |||
Set negative numbers to zero. Do not calculate with negative valu | Excel Discussion (Misc queries) | |||
change 2000 cells (negative numbers) into positive numbers | Excel Worksheet Functions | |||
In Excel, how to sum top 10 greatest values in a row of numbers? | Excel Worksheet Functions |