Thread: CountIfs
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Sheeloo[_5_] Sheeloo[_5_] is offline
external usenet poster
 
Posts: 248
Default CountIfs

There is nothing wrong with your formula... I spend 30 mins to find that out...

You are probably calling it as
=CountBetween1(A1:A10, 10, B1:B10, 20, 5)
which I was doing... and I rewrote everything then realized that your
function signature is
CountBetween1(InRange, num1, num2, InRange1, num3)

see what I mean?
You should call as
=CountBetween1(A1:A10, 10, 20, B1:B10, 5)

:-)

Actually you should change the signature of the function...

I am assuming you are working with EXCEL 2007.

-------------------------------------
Pl. click ''''Yes'''' if this was helpful...



"farid2001" wrote:

Dear Gentlemen

I am trying to get the CountBetween function to work with CountIfs instead
of CountIf, but I am getting nowhere.

This is what I have:

Function CountBetween1(InRange, num1, num2, InRange1, num3) As Integer

With Application.WorksheetFunction
If num1 <= num2 Then
CountBetween1 = .CountIfs(InRange, "=" & num1) -
.CountIfs(InRange, "" & num2) And .CountIfs(InRange1, "=" & num3)
Else
CountBetween1 = .CountIfs(InRange, "=" & num2) -
.CountIfs(InRange, "" & num1) And .CountIfs(InRange1, "=" & num3)
End If
End With
End Function

Your help will be greatly appreciated.

Regards
farid2001