+ Reply to Thread
Results 1 to 4 of 4

If Date and Time are within a Range, Return Specific Text

  1. #1
    Registered User
    Join Date
    03-10-2022
    Location
    Columbus, Ohio
    MS-Off Ver
    Professional Plus 2021
    Posts
    2

    If Date and Time are within a Range, Return Specific Text

    In column A, a 24 hour shift begins on the given date, at 07:00:00 AM.

    In column B, the corresponding shift is listed.

    Given the list of dates and times in column D, how can I return the appropriate shift as shown is column E?

    [the color formatting is not necessary]

    Screenshot (1).png

    Thanks for any help!
    Matt

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,393

    Re: If Date and Time are within a Range, Return Specific Text

    Assuming all the date/time stamps are real numbers and not text, it should be a simple lookup with approximate match options (Most lookup type problems start with the VLOOKUP() function. This is a good tutorial since it includes both exact match and approximate match examples: https://www.ablebits.com/office-addi...ximate-vlookup ).

    Something like =VLOOKUP(D2,$A$2:$B$7,2,TRUE) [note the mix of relative and absolute references, then copy/paste/fill down] should do the job.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    03-10-2022
    Location
    Columbus, Ohio
    MS-Off Ver
    Professional Plus 2021
    Posts
    2

    Re: If Date and Time are within a Range, Return Specific Text

    Thank you for your reply MrShorty!

    After too much time searching the internet, I finally found a formula that works:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It helped to add the end of the range in column B.

    Screenshot (4).png
    Attached Images Attached Images

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,393

    Re: If Date and Time are within a Range, Return Specific Text

    If you like it, that's fine. This formula is mixing different operations with an exact match lookup, which, if you ever need to do this lookup over a large data set, is going to be very performance heavy. I don't see what it is doing that my simpler approximate match formula is doing. I guess this formula seems to me to be a lot more complicated than it needs to be.

+ 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. Return specific line of text based on range of text values entered
    By robjardim in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-12-2022, 06:21 AM
  2. Return Specific Date When it Falls Within a Date Range
    By pbf29078 in forum Excel General
    Replies: 2
    Last Post: 08-08-2020, 12:54 PM
  3. Replies: 4
    Last Post: 03-21-2018, 09:25 AM
  4. Look up Date Range and Return Specific Value
    By Jayeve in forum Excel General
    Replies: 2
    Last Post: 01-19-2016, 05:47 PM
  5. Replies: 9
    Last Post: 10-08-2015, 01:50 PM
  6. [SOLVED] reference date time range, return the value into all cell that match datetime range
    By Jarvco13 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-22-2013, 10:39 PM
  7. [SOLVED] Return specific text if a different text is contained anywhere in a range of cells
    By ciayers in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2013, 05:54 PM

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