Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Values of non-contiguous cells

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Values of non-contiguous cells

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
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
Summing Contiguous Values in a Column? Confused_in_Houston[_2_] Excel Discussion (Misc queries) 6 March 12th 10 09:51 AM
Multiplying Contiguous Values in an Array [email protected] Excel Worksheet Functions 1 May 26th 07 06:46 AM
Finding non contiguous positive values Nick Krill Excel Worksheet Functions 1 March 29th 07 02:09 AM
average values in non-contiguous cells, ignoring 0 values RWormdahl Excel Worksheet Functions 3 October 30th 06 01:06 AM
TTest with values in non-contiguous ranges Kristina Excel Worksheet Functions 6 August 2nd 05 12:02 AM


All times are GMT +1. The time now is 11:14 PM.

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

About Us

"It's about Microsoft Excel"