Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Try to built an UDF to Count until .....

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Try to built an UDF to Count until .....

On 28 Apr, 00:34, "Don Guillett" wrote:
How about
=cur(a2:a8)


It work perfect , it's really great ;
Thank you so much great programmer , you
helped me many few of times
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Try to built an UDF to Count until .....

On 28 Apr, 00:34, "Don Guillett" wrote:
How about


But , if I need to use it for count in a ROW , not in a
COLUMN ? I tried , but I cann't resolved it ...
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Try to built an UDF to Count until .....

Just change the counter to count columns instead of rows.
=cuc(a5:x5)

function cuc(mc)
Application.Volatile
counter = 1
For Each c In mc
If Cells(c.Row, c.Column + 1) = Cells(c.Row, c.Column) Then
counter = counter + 1
Else
Exit For
End If
Next
'MsgBox counter
cuc = counter
End Function

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ytayta555" wrote in message
...
On 28 Apr, 00:34, "Don Guillett" wrote:
How about


But , if I need to use it for count in a ROW , not in a
COLUMN ? I tried , but I cann't resolved it ...




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Try to built an UDF to Count until .....

On 28 Apr, 02:35, "Don Guillett" wrote:
Just change the counter to count columns instead of rows.


IT work !!
Thank you again and again for useing and shareing your
knowledge in interest of my benefit and help
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
built-in footer Lynn Excel Discussion (Misc queries) 4 October 3rd 08 10:07 PM
Referencing .NET DLL built for COM in VBA J. Caplan[_2_] Excel Programming 0 July 24th 08 06:42 PM
Can I do this with built in functions? Conan Kelly Excel Worksheet Functions 3 December 6th 05 08:52 PM
help with pre-built template dvonj Excel Discussion (Misc queries) 0 March 9th 05 04:23 PM
how was this built vincent Excel Programming 1 October 13th 03 09:17 PM


All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"