+ Reply to Thread
Results 1 to 5 of 5

Thread: Nesting the IF, AND and SUMPRODUCT functions across worksheets

  1. #1
    Registered User
    Join Date
    01-07-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    10

    Unhappy Nesting the IF, AND and SUMPRODUCT functions across worksheets

    I'm really new to excel, but was tasked with creating a reservation sheet for our Aquatics Community Center. It has 3 work sheets where one is supposed to be able to enter basic information about reservations for different rooms. On the last sheet is a visual table of the date, the room and the hours and this is supposedly to show the the availability of the rooms and is supposed to fill it self out automatically, based on the information you enter into the first three worksheets.

    Please look at my worksheet (BOOK 1) and the template (COPY OF HOTEL RESERVATIONS) that I am basing it on to get a better picture.

    I tried to create a nested function that would fill a cell with the values of 0,1 or -1 depending on whether certain variables were true or false. I was then intending to format the cells conditionally to turn a different color based on the number.

    This is the code that I used:
    = =IF(AND(ConferenceRooms!$D$2:$D$1001='Schedule&Availabilites'!B$5, ConferenceRooms!$G$2:$G$1001='Schedule&Availabilites'!B$6), 1-SUMPRODUCT((ConferenceRooms!$E$2:$E$1001<='Schedule&Availabilites'!A7)*(ConferenceRooms!$F$2:$F$1001>='Schedule&Availabilites'!A7+1)),"0")
    The AND function is supposed to relate to the room type and the date of the booking. The SUMPRODUCT.... well to be honest I'm not really sure. I tried to modify the code that was used in the template I looked at and I researched it as much as possible, But I'm still struggling to understand.

    If someone could please try and help me out, I would really appreciate it.

    I'm also not sure If I've posted all the information need, so if anything else is require, please just let me know.
    Thanks
    Attached Files Attached Files
    Last edited by slaro; 01-12-2012 at 08:58 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    455

    Re: Nesting the IF, AND and SUMPRODUCT functions across worksheets

    In B7:
    =1-SUMPRODUCT((ConferenceRooms!$D$2:$D$9='Schedule&Availabilites'!$A$3)*(ConferenceRooms!$G$2:$G$9='Schedule&Availabilites'!B$6)*(ConferenceRooms!$E$2:$E$9<='Schedule&Availabilites'!$A7)*(ConferenceRooms!$F$2:$F$9>='Schedule&Availabilites'!$A7))
    Copy down and right.
    1 is available and 0 is occupy.

  3. #3
    Registered User
    Join Date
    01-07-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Nesting the IF, AND and SUMPRODUCT functions across worksheets

    Thank you bebo021999, I see the changes that you've made and they mostly make sense to me. There is one problem though, in terms of the way you linked the booking date to the schedule. You linked it to cell A3, but that cell is just a reference cell for the actual interactive calendar and the plan was for it to be hidden once the workbook is complete.

    What I want is for the booking dates to actually be linked to the interactive calendar dates. So each time there is a new date in the cell, the schedule will change accordingly. The way you've set it up right now, it only works with the ONE date that is in A3.

    Subsequently, I tried changing the linked cell to B$5 and while it worked for the first column (Salon A), when I dragged it across to the Salon B, which is supposed to be under the same date, the cell changed to C$5 and subsequently didn't work.

    1-SUMPRODUCT((ConferenceRooms!$D$2:$D$9='Schedule&Availabilites'!B$5)*(ConferenceRooms!$G$2:$G$9='Schedule&Availabilites'!B$6)*(ConferenceRooms!$E$2:$E$9<='Schedule&Availabilites'!$A7)*(ConferenceRooms!$F$2:$F$9>='Schedule&Availabilites'!$A7))
    I've attached the workbook that I made the changes to so that you can see more clearly what I've done.

    Book1.xls

    To me this shouldn't be happening because if cells are merged then either they should all hold the same information or the formula should automatically skip to the next set of merged cells and ignore the the individual cells that compose a merged cell.

    However that is clearly not the case..... is there any other way then that I can format my table so that I get my desired results?

    Thank you so much by the way!
    Last edited by slaro; 01-08-2012 at 12:02 PM.

  4. #4
    Valued Forum Contributor Haseeb A's Avatar
    Join Date
    05-24-2011
    Location
    India | Kwt
    MS-Off Ver
    2007
    Posts
    1,460

    Re: Nesting the IF, AND and SUMPRODUCT functions across worksheets

    Try this,

    =(SUMPRODUCT(--(ConferenceRooms!$D$2:$D$100=LOOKUP(9E300,$B$5:B$5)),--(ConferenceRooms!$G$2:$G$100=B$6),--(ConferenceRooms!$F$2:$F$100>=$A7),--(ConferenceRooms!$E$2:$E$100<=$A7+"00:29"))=0)+0
    Copy across & down

    If you are on XL2007 or later replace SUMPRODUCT with COUNTIFS, which is faster than SUMPRODUT.
    HTH; Haseeb

    If your problem is solved, please say so clearly, and mark your thread as Solved:
    Forum Rules & How to Mark a thread as SOLVED

  5. #5
    Registered User
    Join Date
    01-07-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Nesting the IF, AND and SUMPRODUCT functions across worksheets

    Haseeb,

    If I could hug you I would!
    This works PERFECTLY! Thank you so much for helping me out! I'm not quite sure I understand everything you did with this code, but I am going to research more and I'm determined to understand. But for the time being, you have helped me out a great deal and I really appreciate it!

    Thank you again for everything!
    Samantha

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0