View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Find First Negative Number after 'X' has been reached

Hi,

Am Fri, 5 Sep 2014 19:01:49 +0100 schrieb dwg1803:

-5, 5, -2, 4, -2, 10, 4, 11

in Cell K1 = 3

I need a formula that will tell me which position in Row 3; where after
the value in K1 has been exceeded, I need the position of the next time
i have a value of less than or equal to "Zero"


copy following code in a standard module and call the function in the
worksheet in row 3 with
=myCol()

Function myCol() As Long
Dim i As Long
Dim myRow As Long

myRow = Application.Caller.Row
For i = 1 To 8
If Cells(myRow, i) = Range("K1") And _
Cells(myRow, i + 1) <= 0 Then
myCol = i + 1
Exit For
End If
Next
End Function


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional