Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I am looking for a function that that can be used to replace the COUNTIF worksheet function, but works on non-contiguous cells. Can someone point me in the right direction. Thanks Tony |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe something like this:
Public Function MyCountif(ParamArray v()) Dim tot As Long, c As Variant Dim rng As Range tot = 0 c = v(UBound(v)) For i = LBound(v) To UBound(v) - 1 Set rng = Nothing On Error Resume Next Set rng = v(i) On Error GoTo 0 If Not rng Is Nothing Then tot = tot + Application.CountIf(v(i), c) End If Next MyCountif = tot End Function Make sure you put it in a general module sample usage: =mycountif(A2:A5,C2:C5,E2:E5,H2:H5,""&I2) -- Regards, Tom Ogilvy "TJ" wrote in message ... Hi I am looking for a function that that can be used to replace the COUNTIF worksheet function, but works on non-contiguous cells. Can someone point me in the right direction. Thanks Tony |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Summing Contiguous Values in a Column? | Excel Discussion (Misc queries) | |||
Multiplying Contiguous Values in an Array | Excel Worksheet Functions | |||
Finding non contiguous positive values | Excel Worksheet Functions | |||
average values in non-contiguous cells, ignoring 0 values | Excel Worksheet Functions | |||
TTest with values in non-contiguous ranges | Excel Worksheet Functions |