+ Reply to Thread
Results 1 to 37 of 37

How to prevent double room reservation Hi

  1. #1
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    How to prevent double room reservation Hi

    Hi,
    i want to make room reservation in excel. But I could not find out how to prevent double booking

    I want to be warned when I enter a date I have already given for the same room
    Can anyone help me please

    I cant VBA!!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: How to prevent double room reservation Hi

    Hi,
    please test this in E2 and down:
    =IF(SUM((A2=$A$2:$A$6)*(C2>=$C$2:$C$6)*(D2<=$D$2:$D$6))-1,"double booking","OK to book")

  3. #3
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by belinda200 View Post
    Hi,
    please test this in E2 and down:
    =IF(SUM((A2=$A$2:$A$6)*(C2>=$C$2:$C$6)*(D2<=$D$2:$D$6))-1,"double booking","OK to book")
    thank for your quick support Belinde but it is not woking ! i add your code to the excel sheet and sendign as atachment
    Attached Files Attached Files

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to prevent double room reservation Hi

    We need to understand a bit more.

    Is the list you show always in the order of bookings as they come in which will never be altered, or will it be sorted at any point by either room, name or date.

    The solution will depend on understanding this. Essentially can we rely on all the the rows above a new booking always being in chronological order of the date they are entered to Excel(and I don't mean the check in date)?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: How to prevent double room reservation Hi

    Hi,
    1. You are right
    2. Please remove the @ from the formula
    3. please test this one:
    =IF(SUM((A2=$A$2:$A$6)*(C2>=$C$2:$C$6)*(C2<$D$2:$D$6))-1,"double booking","ok to book")
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Belinda you are an angel THANK You VERY MUCH

  7. #7
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: How to prevent double room reservation Hi

    I suggest you do test it with several scenarios and pay attention to what @Richard Buttrey wrote...
    Good Luck.

  8. #8
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by Richard Buttrey View Post
    We need to understand a bit more.

    Is the list you show always in the order of bookings as they come in which will never be altered, or will it be sorted at any point by either room, name or date.

    The solution will depend on understanding this. Essentially can we rely on all the the rows above a new booking always being in chronological order of the date they are entered to Excel(and I don't mean the check in date)?
    I am sorry for my late response Richard, the answers to both of your questions is yes.

  9. #9
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Dear Belinda your formula is working at your excel sheet but when i copied to my excel sheet it does not working, can you tell me what am i doing wrong? (attached my file) !
    at your excel shett show { } at beginnig and the of the formula but not on my sheet.
    And one more question : how can i use this code as data validation under column c and d?
    regards
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by bmkucuk View Post
    Belinda you are an angel THANK You VERY MUCH
    Hi
    I added the sign "=" to the formula in case the new guest arrives on same day the other is leaving and it considers double booking....

    =IF(SUM((A2=$A$2:$A$6)*(C2>=$C$2:$C$6)*(C2=<$D$2:$D$6))-1,"double booking","ok to book")

  11. #11
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by bmkucuk View Post
    .............. it does not working, can you tell me what am i doing wrong? .........
    Hi,
    The formula is CSE type.
    Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

    Or you can change the SUM to SUMPRODUCT:

    =IF(SUMPRODUCT((A2=$A$2:$A$6)*(C2>=$C$2:$C$6)*(C2=<$D$2:$D$6))-1,"double booking","ok to book")
    Last edited by Limor_OP; 01-01-2021 at 02:25 PM.

  12. #12
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by bmkucuk View Post
    ......how can i use this code as data validation under column c and d?
    what kind of a data validation you want in columns C and D ? Please explain.

  13. #13
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,775

    Re: How to prevent double room reservation Hi

    C2=<$D$2:$D$6)
    C2<=$D$2:$D$6)
    Note the = needs to be to the right of a < or >
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  14. #14
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: How to prevent double room reservation Hi

    You're right etaf
    The excel auto corrects this syntax error...

  15. #15
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    I want it to work with the same logic ! if there is a date range entered for the same room, it shouldn't allow it. Thank you)

  16. #16
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by belinda200 View Post
    what kind of a data validation you want in columns C and D ? Please explain.
    I want it to work with the same logic ! if there is a date range entered for the same room, it shouldn't allow it. Thank you

  17. #17
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,612

    Re: How to prevent double room reservation Hi

    Use data --> validation so that you can prevent the double entry itself.
    Select Range C2:C7
    Data --> Validation
    Custom
    Enter the formula

    =SUMPRODUCT(($A$1:$A1=$A2)*($C$1:$C1<=$C2)*($D$1:$D1>=$C2))=0

    For range $D2:$D7 formula

    =$C2<>""

    This will not allow the dates in column C if it is already booked.
    In Range D cannot be entered unless column C is filled. That is if C7 is vacant D7 cannot be filled.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  18. #18
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Thank you very much, smooth as silk, I am very grateful
    Last edited by AliGW; 01-02-2021 at 06:30 AM. Reason: PLEASE don't quote unnecessarily!

  19. #19
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: How to prevent double room reservation Hi

    If the idea is to prevent double booking of rooms, isn't it better to check for availability date for each room?
    E1 = "Availability Date"
    E2 = IF(ISBLANK(A2),"",AGGREGATE(14,6,D$2:D2/(A$2:A2=A2),1)+1)

  20. #20
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Could you please put your formulation on my sample page and post here please?
    Last edited by AliGW; 01-02-2021 at 07:02 AM. Reason: PLEASE stop quoting unnecessarily!

  21. #21
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: How to prevent double room reservation Hi

    If the idea is to prevent double booking of rooms, isn't it better to check for availability date for each room?
    E1 = "Availability Date"
    E2 = IF(ISBLANK(A2),"",AGGREGATE(14,6,D$2:D2/(A$2:A2=A2),1)+1)
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by josephteh View Post
    If the idea is to prevent double booking of rooms, isn't it better to check for availability date for each room?
    E1 = "Availability Date"
    E2 = IF(ISBLANK(A2),"",AGGREGATE(14,6,D$2:D2/(A$2:A2=A2),1)+1)
    Thank you for your support but when i have many entrances i have to check it out one by one, it is imposible to that
    And it is not working anyway because it is calculate the checkout date.
    room 11 booked fr 01/04 to 04/04
    room 11 booked fr 06/04 to 09/04
    accordind to this calculation first avaliable date is 10/04
    but 05/04 is availbale too ! )

  23. #23
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: How to prevent double room reservation Hi

    So, you do allow for double-booking of rooms to maximise profits in case some guests do not turn up?

  24. #24
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by josephteh View Post
    So, you do allow for double-booking of rooms to maximise profits in case some guests do not turn up?
    On the contrary, I have already asked for help not to do this and I have received what I wanted. If you check post numer 9 and 17 you can see it.

  25. #25
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: How to prevent double room reservation Hi

    Why do you need to check one by one? Once you key in the room number in column A, availability of the room would be shown in column E at the same row.

    On the contrary, data validation only blocks you from entering non-available dates and does not tell you when the room is available.

  26. #26
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,612

    Re: How to prevent double room reservation Hi

    Sorry for the mistake.
    Formula I have given in post #17 for column D validation is not full proof. I have checked it. So the revised formula for Validation of Column D is

    =AND($C2<>"",SUMPRODUCT(($A$1:$A1=$A2)*($C$1:$C1>$C2)*($C$1:$C1<=$D2))=0)

    Pl change it.
    Attached Files Attached Files

  27. #27
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by josephteh View Post
    Why do you need to check one by one? ...

    Please check this spreadsheet maybe you can understand what I have said before!
    As you can see between 10 and 13 room 11 is available, but it shows 17 as the first available date
    Because formula calculates the last check-out day! But there are available dates in between. What will happen if i sell room 11 1/5 today ???
    You need to understand how a booking system works.
    Attached Files Attached Files
    Last edited by AliGW; 01-02-2021 at 08:09 AM.

  28. #28
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Quote Originally Posted by kvsrinivasamurthy View Post
    Sorry for the mistake....

    I noticed this too, but I didn't want to disturb you any more, thank you again.
    Last edited by AliGW; 01-02-2021 at 08:08 AM.

  29. #29
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: How to prevent double room reservation Hi

    Thank you, bmkucuk. I understand now. Bookings for earlier dates can come in later.

  30. #30
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,418

    Re: How to prevent double room reservation Hi

    Administrative Note:

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below or the REPLY button instead of REPLY WITH QUOTE.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  31. #31
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    I am sorry Ali

  32. #32
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    Hi kvsrinivasamurthy,
    if I remove the formula from data validation and then paste it again it does not work
    Or if I put the formula on another page it does not work either.
    But it works on your sheet, I'm doing something wrong but what?
    Any Idea?

    =AND($C2<>"";SUMPRODUCT(($A$1:$A1=$A2)*($C$1:$C1>$C2)*($C$1:$C1<=$D2))=0)

  33. #33
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,612

    Re: How to prevent double room reservation Hi

    Validation works only when there is new entry in the cell. If data is already existing before applying validation it will not validate. If you can upload sample file it can checked.

  34. #34
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    I am sending sample file.
    Attached Files Attached Files

  35. #35
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,612

    Re: How to prevent double room reservation Hi

    I asked for sample file not so simple file. Ok . That is just for joke.
    Pl see the uploaded file.
    In the sheet Sayfa1 formula for data validation for Column D is
    Please Login or Register  to view this content.
    For Column C No change in Previous formula.
    Data validation takes care of new entry only. If already existing rows are edited validation takes care of rows above only. This problem can be avoided by using worksheet event . Same is given in Sheet1.

    Code :
    Please Login or Register  to view this content.
    Worksheetevent

    To paste the code
    Right click on Sheet tab --> view code
    VB window opens.
    Paste the code
    Close the window.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 01-03-2021 at 10:42 AM.

  36. #36
    Registered User
    Join Date
    01-01-2021
    Location
    nosey
    MS-Off Ver
    excel 2019
    Posts
    17

    Re: How to prevent double room reservation Hi

    The god of Excel, I must bow to your superior knowledge, Thank you again,You are the one

  37. #37
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,612

    Re: How to prevent double room reservation Hi

    Thanks for the feedback and good words.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to Calculate Hotel room nights booked, for each night, and broken down by room type?
    By salsadantzr in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-09-2018, 04:53 PM
  2. Room Allotment:remove allotted room from dropdown list
    By amdrosm in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-05-2017, 04:50 AM
  3. Converting tabular data into room-by-room
    By tomca in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-03-2016, 07:00 AM
  4. Automatic prevent of double values
    By yosisarid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2015, 04:19 AM
  5. [SOLVED] Hotel Rooming List, sorted by category of room (Single Double etc)
    By Robert.Appel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-02-2014, 06:17 AM
  6. double reservation in a Excel booking system
    By Janoz in forum Excel General
    Replies: 3
    Last Post: 11-05-2013, 10:00 PM
  7. [SOLVED] How to prevent double entry in excel?
    By George Teng in forum Excel General
    Replies: 3
    Last Post: 03-15-2005, 04:06 AM

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.6.0 RC 1