+ Reply to Thread
Results 1 to 6 of 6

If functions with Two different time ranges

  1. #1
    Registered User
    Join Date
    07-25-2017
    Location
    Jeddah
    MS-Off Ver
    2013
    Posts
    13

    If functions with Two different time ranges

    Hello,

    I'm trying to create if function to test if an value falls in one of the two time ranges. For that endded up with the followin function but it did not work.

    IF(OR(AND(D1>=StartTime1, D1>=EndTime1), OR(D1>=StartTime2, D1>=EndTime2)), "Yes", "No")

    Could anyone tell me what I'm missing.

    Thank you

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: If functions with Two different time ranges

    Try

    =IF(OR(AND(D1>=StartTime1, D1<=EndTime1), OR(D1>=StartTime2, D1<=EndTime2)), "Yes", "No")

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: If functions with Two different time ranges

    I think you need to reverse the 2nd > in each AND

    AND(D1>=StartTime1, D1>=EndTime1)
    Should probably be
    AND(D1>=StartTime1, D1<=EndTime1)

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: If functions with Two different time ranges

    And your 2nd OR should be an AND

    Try
    IF(OR(AND(D1>=StartTime1, D1<=EndTime1), AND(D1>=StartTime2, D1<=EndTime2)), "Yes", "No")

  5. #5
    Registered User
    Join Date
    07-25-2017
    Location
    Jeddah
    MS-Off Ver
    2013
    Posts
    13

    Re: If functions with Two different time ranges

    Thank you all, that worked

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: If functions with Two different time ranges

    You're welcome.

+ 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] variables for ranges and their use in functions.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-12-2013, 04:02 PM
  2. Using Formula and/or Functions in VBA for Ranges
    By excel0831 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-28-2012, 10:00 PM
  3. Named Ranges & Functions - Problem
    By teo_7 in forum Excel General
    Replies: 12
    Last Post: 01-17-2012, 03:08 AM
  4. [SOLVED] Copy and SUM functions with different ranges
    By Manos in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-01-2006, 03:20 AM
  5. [SOLVED] Confused about arrays and ranges in functions
    By Llurker in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 AM
  6. Confused about arrays and ranges in functions
    By Llurker in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. if functions with more than 7 ifs (ranges are possible?)
    By irwinko in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-17-2005, 08:06 AM
  8. [SOLVED] Ranges in Custom Functions
    By JR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2005, 11: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