Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

countif

ResolvedVersion 2003

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

Attached files...

Dcount.xls

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Applying and removing border from cell in Excel 2010

Did you know the shortcut key for applying and removing the outline border for a cell?

CTRL+SHIFT+& Applies the outline border to the selected cells.
CTRL+SHIFT_ Removes the outline border from the selected cells.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.