View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Try to built an UDF to Count until .....

How about
=cur(a2:a8)

Function cuR(mc)'for a range
Application.Volatile
counter = 1
For Each c In mc
If Cells(c.Row + 1, c.Column) = Cells(c.Row, c.Column) Then
counter = counter + 1
Else
Exit For
End If
Next
cuR = counter
End Function
========
=cu("a") for column A

Function cu(mc)'
Application.Volatile
counter = 1
For i = 1 To Cells(Rows.Count, mc).End(xlUp).Row
If Cells(i + 1, mc) = Cells(i, mc) Then
counter = counter + 1
Else
Exit For
End If
Next i
cu = counter
End Function


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ytayta555" wrote in message
...
HI , and a good week , programmers !

I need a UDF to count until it find
the same value in a range of cells :

eg: in A1 is value TRUE , in A2 the same value ,
in A3 the same value ( TRUE ) , in A4 the same value ,
but in cell A5 the value is FALSE ; in cell A6 the value is
again TRUE , etc .
the good result of this UDF is 4 , because I need this
UDF to count only untill it find the same value ;

Please very much to help me , and thousand
of thanks in advance