+ Reply to Thread
Results 1 to 5 of 5

Data validation with 2 number ranges

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Data validation with 2 number ranges

    I am working on a project tracking spreadsheet and developing a summary sheet where the user can select a project and report on the income, spend, etc data which is stored in tables on various other sheets. The projects run for several weeks, some of which span two years. I want the user to be able to enter the week number for which they want to see the details, but also need to validate that they have chosen a week covered by the project.

    If the project is all in the same year, I can use Whole Number validation and just check the entry is between the start and end week. But if the project spans two years the validation needs to check 2 number ranges. For example, if the project starts in week 25, 2016 and ends in week 18, 2017 the validation needs to permit numbers 25 to 52 or 1 to 18.

    Note that a project can never span more than 52 weeks.

    Any ideas on if this is possible, or will I just need to include the year as part of the validation criteria?

    I've attached a small sample workbook.
    Attached Files Attached Files
    Excel is a constant learning process and it's great to help each other. If any of us have helped you today, a click on the "reputation" star on the left is appreciated.

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2021
    Posts
    5,969

    Re: Data validation with 2 number ranges

    Try this ...

    =OR(AND(C10>=C5,C10<=52),AND(C10>0,C10<=C6))

    Or try this ...

    =OR((C10>=C5)*(C10<=52),(C10>0)*(C10<=C6))

  3. #3
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Data validation with 2 number ranges

    Perfect! Obvious when I think about it

    Many thanks for your help

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,852

    Re: Data validation with 2 number ranges

    Maybe you should treat them as a continuous range, i.e. from week 25 (in 2016) to week 70 (also counted as if from 2016), then you can use MOD(..., 52) to get the year offset.

    Hope this helps.

    Pete

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,915

    Re: Data validation with 2 number ranges

    =IF(D5=D6,AND(C10>=C5,C10<=C6),IF(D6-D5=1,OR(C10>=C5,C10<=C6),AND(C10>0,C10<53)))
    Try this formula in data validation
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

+ 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] dynamic and dependent data validation ranges
    By AColonyOfAnts in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-20-2014, 11:38 PM
  2. Dynamic Name ranges and data validation problems
    By rikkyshh in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-19-2013, 01:29 PM
  3. Data Validation for multiple ranges
    By KML123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2013, 05:42 PM
  4. [SOLVED] Data Validation with multiple name ranges.
    By bryans2094 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 04-27-2013, 05:18 PM
  5. Data Validation and Dynamic Named Ranges
    By freybe06 in forum Excel General
    Replies: 15
    Last Post: 07-20-2011, 01:18 PM
  6. Data Validation with name ranges
    By ABabeNChrist in forum Excel General
    Replies: 5
    Last Post: 04-14-2010, 12:05 AM
  7. Data validation using multiple ranges
    By madbloke in forum Excel General
    Replies: 4
    Last Post: 06-09-2006, 09:43 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