If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > A Tricky COUNTIF problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-11, 23:46
MatthewM MatthewM is offline
Registered User
 
Join Date: Mar 2007
Posts: 15
[SOLVED]A Tricky COUNTIF problem

Hey all,

What I would love this spreadsheet to do is to count the number of "Hit" entries in column B that are on or between the start date and, depending on which one comes first, the End date or todays date. I would like this to be done in cell F5 under "Count". You can see the formula I have in there at the moment is not good enuff to do this but can only count ALL "Hit" entires regardless of date.

Put another way, I want to be able to change the start date and end date to whatever I like and see cell F5 re-calculate to show how many "Hit's" are on or between the dates indicated, and if a future end date is entered, to ignore this and instead use todays date.

Using Excel 2003, really hope someone can help me this is an extract of a much larger project and would add an incredible amount of quality if it can be done.

Sincerley,

Matty

SOLVED WITH:

=SUMPRODUCT((A2:A389>=C5)*(A2:A389<=E5)*(B2:B389=" Hit")*(A2:A389<=D5))

Thanks to anyone who has pondered over this, with a bit of intense gear grinding I worked this formula out that seems to do what I want (shown above).

If anyone has anything to add be happy to hear it.

Cheers guys
Attached Files
File Type: zip needhelpcounting.zip (9.5 KB, 5 views)

Last edited by MatthewM; 01-06-11 at 18:03. Reason: Solved
Reply With Quote
  #2 (permalink)  
Old 01-07-11, 11:28
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hi Matt,

You can simplify your formula to one of this:
Code:
=SUMPRODUCT((A2:A389>=C5)*(A2:A389<=MIN(D5,E5))*(B2:B389="Hit"))
For consistency, I think the word Hit should also be put in a cell to be referenced.

A more efficient formula option would be to use the DCOUNT() function, but to use it you would have to structure your criteria fields differently. If you're interested I can give you an example of this.

Hope that helps...
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #3 (permalink)  
Old 01-11-11, 00:11
MatthewM MatthewM is offline
Registered User
 
Join Date: Mar 2007
Posts: 15
Hey Colin,

Thanks for the reply, it was interesting to see how you used the MIN in there. I've also played around with DSUM and DCOUNT and they work great too.

Thanks heaps, this has solved a really big headache for me

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On