Countif with multiple criteria and date ranges

weaz1991

New Member
Joined
Jan 21, 2009
Messages
3
Need a bit of help with this. Doing a project for a made up hotel, in essence I have 3 columns, Arrival date, leave date, and rate.

Arrival date and leave date are self explanatory. The rate is either: "EB", "NP" or "WI", and the rate is decided based on when the room was booked, but is not really relevant.

What i need to do is count up how many rooms are booked on a given day, and of those booked on that day how many are "EB", for example.

I have a solution, but it is impractical. I have used the conditional sum wizard, and a list of hidden numbers to solve the problem, but i am trying to change it to a better formulae.

A big problem is that I am using dates. I have a list of dates 30 long that need finding out and along with three rates it makes 90 formulae, each one with 2 dates in them that need changing by hand, 180 changes that i could really do without.

i was hoping you could help me.

Below is a mock up of the table of data.

Arrival date Leave Date Rate
30/11/2008 01/12/2008 NP
30/11/2008 01/12/2008 EB
29/11/2008 01/12/2008 NP
29/11/2008 30/11/2008 WI
29/11/2008 30/11/2008 NP
28/11/2008 01/12/2008 NP
28/11/2008 01/12/2008 EB
28/11/2008 01/12/2008 EB
28/11/2008 01/12/2008 EB
28/11/2008 30/11/2008 EB
28/11/2008 30/11/2008 EB
28/11/2008 29/11/2008 WI
28/11/2008 29/11/2008 WI
27/11/2008 02/12/2008 EB
27/11/2008 01/12/2008 NP
27/11/2008 01/12/2008 EB
27/11/2008 30/11/2008 EB
26/11/2008 02/12/2008 EB
26/11/2008 01/12/2008 EB
26/11/2008 30/11/2008 NP
26/11/2008 29/11/2008 EB

The actual formulae will go on a different sheet, in a table

Date EB Rooms NP Rooms WI Rooms
30/11/2008
29/11/2008
28/11/2008
27/11/2008
26/11/2008
25/11/2008
24/11/2008

I really need help with it and would be glad of any.

Thanks,

Weazel

Also, it would be even better if a formulae could be copied and pasted down the columns, going along is no problem as there are only 3 columns.
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
try this
Macros for MrExcel.xls
ABCD
1ArrivaldateLeaveDateRate
211/30/200812/01/2008NP
311/30/200812/01/2008EB
411/29/200812/01/2008NP
511/29/200811/30/2008WI
611/29/200811/30/2008NP
711/28/200812/01/2008NP
811/28/200812/01/2008EB
911/28/200812/01/2008EB
1011/28/200812/01/2008EB
1111/28/200811/30/2008EB
1211/28/200811/30/2008EB
1311/28/200811/29/2008WI
1411/28/200811/29/2008WI
1511/27/200812/02/2008EB
1611/27/200812/01/2008NP
1711/27/200812/01/2008EB
1811/27/200811/30/2008EB
1911/26/200812/02/2008EB
2011/26/200812/01/2008EB
2111/26/200811/30/2008NP
2211/26/200811/29/2008EB
Sheet4
Macros for MrExcel.xls
ABCD
1DateEBRoomsNPRoomsWIRooms
211/30/2008110
311/29/2008021
411/28/2008512
511/27/2008310
611/26/2008310
711/25/2008000
811/24/2008000
Sheet6
 
Upvote 0
This works for me on your data, with data on Sheet1, results on Sheet2:

=SUMPRODUCT((Sheet1!$A$2:$A$22=Sheet2!$A2)*(Sheet1!$C$2:$C$22=Sheet2!B$1))
 
Upvote 0
I appreciate what you have done, But the formulae you have given only show the results were the arrival date and the rate are the same. The things is that if the date you are looking for, say the 28/12/08, is between the arrival date and leave date that needs to be checked against the rate, your formulae only checks the arrival date against the rate.

Bad on my part, didn't explain it all that well, would you be so kind as to give it another go?
 
Upvote 0
I appreciate what you have done, But the formulae you have given only show the results were the arrival date and the rate are the same. The things is that if the date you are looking for, say the 28/12/08, is between the arrival date and leave date that needs to be checked against the rate, your formulae only checks the arrival date against the rate.

Bad on my part, didn't explain it all that well, would you be so kind as to give it another go?

Indeed, I missed. My apologies. try this instead:

=SUMPRODUCT((Sheet1!$A$2:$A$22<=Sheet2!$A2)*(Sheet1!$B$2:$B$22>=Sheet2!$A2)*(Sheet1!$C$2:$C$22=B$1))
 
Upvote 0
got it now, from the original formulae i changed the = to <=. I then copied the formulae changed the criteria to check to the leave date, I then took the arrive date formulae, from the leave date formulae to give the number of rooms booked on a given date, with the given rate.

=(SUMPRODUCT(--(Arrival dates<=Check date),--(Rates=Check rate)))-(SUMPRODUCT(--(Leave Dates<=Check Date),--(Rate=Check Rate)))

Thanks for the help, would not have done it with out you!

Weazel
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top