Angelo has attended:
Excel Advanced course
Excel VBA Intro Intermediate course
Access Advanced course
Access VBA course
Countif
I have two columns of data starting at A1 & B1. A1 people's age. B1 is Boolean 0 or 1 for whether or not they have a disease (0 = no, 1 = yes). I need to count the number of rows where Age < 30 and Disease = 1. The "30" and the "1" need to refer to cells so that I can change both values without having to change any code. The "<" and "=" will stay the same. Ideally, this would be part of an invented function in VBA such as =ROC(Disease,1,Age,30)= the number of people under 30 with the disease.
Thank you in advance.
RE: Countif
Hi Angelo
Thanks for your question
You can achieve the above by using a DCOUNT function. The DCOUNT is a database function. You need to create a "criteria range" with the conditions you specify, and then simply use the paste function wizard to build the function.
It has three arguments; the range of your list, the field that you wish to count and the criteria range.
You can vary the criteria by changing the values in the criteria range
I enclose a sample workbook for your information.
Regards
Stephen