+ Reply to Thread
Results 1 to 5 of 5

How can I use data validation to restrict specific combinations of numbers in a column?

  1. #1
    Registered User
    Join Date
    03-25-2021
    Location
    Canada
    MS-Off Ver
    2016 (work)
    Posts
    3

    How can I use data validation to restrict specific combinations of numbers in a column?

    I work in admin at one of my local hospital, due to COVID, all visits are on an appointment-only basis. We can't have more than one visitor per room per 24h. The gov considers dual beds rooms to be one room so only one visitor per 24h is allowed in dual bed rooms.

    Because of staff permutation and high volume of calls, errors and duplicates are occurring, I am working on a table to mitigate the hassle.

    Dual bed rooms use the same format than single bed ones. In a dual beds rooms, bed 1 and bed 2 are assigned two distinct rooms numbers.

    I use this formula in a custom data validation rule to prevent duplicates (take note that I'm using french, it's the COUNTIF function):

    =NB.SI(C:C,C6)=1

    I now need to add a rule to prevent specific combinations of numbers in a column. ex: 1004 and 1006 in the same column would trigger an error message.

    I wrote this formula (ET=AND NB.SI=COUNTIF):

    =ET(NB.SI(C:C,1004)=1,NB.SI(C:C,1006)=1)

    How do I combine them into a single data validation rule?

    The goal is to create a foolproof work tool for bottom end employees and promote staff permutation.
    Attached Files Attached Files
    Last edited by ChuckJ; 03-25-2021 at 11:30 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,996

    Re: How can I use data validation to restrict specific combinations of numbers in a column

    How about this:

    set up a list of prohbited combinations (here in U1 and U2). Use this as conditional formattning:

    IF(ISNA(MATCH($C6,$U$1:$U$2,0)),FALSE,SUM(COUNTIF($C$6:$C$94,$U$1:$U$2))>1)

    If you add another room to the list (e.g. 1984), extend the bits in red (or we can get Excel to do that for you if they are liable to change regularly), then any combination 1004, 1006 and 1984 where >1 is present will trigger a red flag.

    HOWEVER>>> I am not entirely sure that that is what you really want. We'll see...
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: How can I use data validation to restrict specific combinations of numbers in a column

    I am not sure it is what you want. Can you clarify

    in 24hrs is this time dependent, or is it one visitor per day? eg could I visit at 9pm one day and 10:30am the next? or is this less than 24hrs so not allowed.
    What happens if the patients change in the room, is it out of action for 24hrs so does not matter anyway?
    Do you have to stick to this format?

    I am suspecting one visit per day and Glenn is close!, but you do have hours going down in column A

  4. #4
    Registered User
    Join Date
    03-25-2021
    Location
    Canada
    MS-Off Ver
    2016 (work)
    Posts
    3

    Re: How can I use data validation to restrict specific combinations of numbers in a column

    Sorry if I was not clear enough, maybe it's the language barrier.

    Davsth, it is one visitor per day, the hours on the left are only for scheduling appointments. If a patient leave a room there is a 24-48 hours, at least, gap to allow disinfection.

    We have both single and double rooms in the wards, I need to prevent duplicate for every rooms and prevent the combination of double rooms numbers.
    Ideally, I'd like to use a custom data validation rule

    Thank you Glenn, that would be a great way to do it using conditional formatting .

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,996

    Re: How can I use data validation to restrict specific combinations of numbers in a column

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

+ 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] Data validation for specific text and numbers
    By chaiyya345 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-10-2020, 09:37 PM
  2. Replies: 3
    Last Post: 03-30-2019, 12:48 PM
  3. Data Validation with specific list of numbers
    By Queenofmycastle in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-01-2019, 02:33 PM
  4. Replies: 1
    Last Post: 01-14-2018, 11:04 AM
  5. [SOLVED] Data validation to enter specific numbers
    By YasserKhalil in forum Excel General
    Replies: 5
    Last Post: 01-20-2017, 05:52 PM
  6. How to restrict data validation values in column wise
    By udaykundapur in forum Excel General
    Replies: 1
    Last Post: 01-09-2014, 12:39 AM
  7. Replies: 4
    Last Post: 08-30-2013, 11:40 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