View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jean-Pierre D via OfficeKB.com Jean-Pierre D via OfficeKB.com is offline
external usenet poster
 
Posts: 31
Default function malfunctioning using countif and a variable

Hi,

I have the following function

Function cohort(stap As Double) As Double
cohort = Application.CountIf(Worksheets("deelnemers").Range ("D3:D992"),
"<stap+5") - Application.CountIf(Worksheets("deelnemers").Range ("D3:D992"),
"<stap")
End Function

The problem is that the function does not recognise "stap" in the function.
If i replace stap with a number then the function works. but i need the
number to be a variable..

some additional info
on sheet "deelnemers" there is a list of people with ages in column D
stap is the age of the people. So for example i want to know the number of
people between 30(stap + 5) and 25(stap)

I've been puzzling for ours but no result other then i know wher the function
goes wrong.
any adeas ?


--
Message posted via http://www.officekb.com