I am using excel 97 and I want to count the number of entries between a date range. I have entered =countif(a1:a40,”>09/01/01 and <11/30/01"). I only get zeros. Can anyone help??
Thanks,
Deborah
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » CountIF
If you’d like to see a great discussion of date intervals, go to Chip Pearson’s web site.
Hi Deborah
Try this userdefined function
Function CountDateBetween(inRange, minDate As Date, maxDate As Date)
Dim MinCtr, MaxCtr As Integer ‘counter for dates exceeding limits
MinCtr = Application.CountIf(inRange, “>=” & minDate)
MaxCtr = Application.CountIf(inRange, “>” & maxDate)
CountDateBetween = MinCtr – MaxCtr
End Function
Copy & paste into the personal workbook macros. This workbook is normally hidden.
You will be then able to invoke thefunction using the function wizard (fx button) from the user defined category.
Cheers
Geof
Here is the formula again before I try to explain:
=SUM((A1:A40 > DATEVALUE("9/1/01")) * (A1:A40 < DATEVALUE("11/30/01")))
Since this is entered as an array formula, the (A1:A40 > DATEVALUE(“9/1/01”) part of the formula will compare the dates in cells A1 through A40 to the date 9/1/01 and create an array of forty ones or zeros. There will be a one in the array where the date in the corresponding cell is greater than 9/1/01, and a zero where it is less. The second part of the formula creates a second array with ones where the date is less than 11/30/01 and a zero where it is greater. The asterich (*) multiplies the those two arrays together to create an array where the elements are one if the date in the corresponding cell is between the dates and a zero if it is outside the range. The SUM adds uo the elements in this array which counts the dates in the range.
There is no & in the formula, so I don’t know what you are asking there.
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.