View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Niek Otten Niek Otten is offline
external usenet poster
 
Posts: 3,440
Default function malfunctioning using countif and a variable

"<"&stap&"+5"

--
Kind regards,

Niek Otten

Microsoft MVP - Excel

"Jean-Pierre D via OfficeKB.com" wrote in message
...
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