+ Reply to Thread
Results 1 to 4 of 4

Data Validation: Comparing 2 timestamps - If time, then may not =, if string, then allowed

Hybrid View

  1. #1
    Registered User
    Join Date
    02-15-2017
    Location
    Cape Town, South Africa
    MS-Off Ver
    Microsoft Excel 2016 MSO (16.0.7571.7095) 64-bit
    Posts
    12

    Question Data Validation: Comparing 2 timestamps - If time, then may not =, if string, then allowed

    Hi There,

    I'm having some trouble solving the following Data Validation Problem:

    I have two columns H and I. Column H cells contain start-times [HH:MM:SS] and cells in column I contain end-times [HH:MM:SS].

    However, cells in these two columns can also contain specific strings like "NA" / "Skipped". Only if the start- and end-time values are time values, the may not be equal to each other. However, if the cells in columns H or I contain any of the String values, they may equal each other. Otherwise it must show an error.

    I have come this far:
    =AND(OR(TEXT($I3,"hh:mm:ss")="NA",TEXT($I3,"hh:mm:ss")="Aborted",TEXT($I3,"hh:mm:ss")="Skipped",NOT(ISERROR(TIMEVALUE(TEXT($I3,"hh:mm:ss"))))),NOT(TEXT($H3,"hh:mm:ss")=TEXT($I3,"hh:mm:ss")))

    The above formula works, but it does not allow the H+I cells to be the same in case they are string values... It stops any values compared in columns H+I from being the same, no matter what.

    I will greatly appreciate any suggestions!

    Thanks.
    Last edited by LeafyShroom; 02-15-2017 at 04:13 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,923

    Re: Data Validation: Comparing 2 timestamps - If time, then may not =, if string, then all

    I get this:

    Formula: copy to clipboard
    =OR(AND(OR($I3="NA",$I3="Aborted",$I3="Skipped"),$H3=$I3),AND(NOT(ISERROR(TIMEVALUE(TEXT($I3,"hh:mm:ss")))),NOT(ISERROR(TIMEVALUE(TEXT($H3,"hh:mm:ss")))),$H3<>$I3))


    I interperted your rule as:

    Result is TRUE if:
    1. Both values are valid times and are different*
    2. Both values are valid text strings and the same

    Result is FALSE in all other cases

    *You didn't say so but you should probably ensure that end time is later than start time.
    Last edited by 6StringJazzer; 02-16-2017 at 04:00 PM. Reason: added text below formula
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    02-15-2017
    Location
    Cape Town, South Africa
    MS-Off Ver
    Microsoft Excel 2016 MSO (16.0.7571.7095) 64-bit
    Posts
    12

    Re: Data Validation: Comparing 2 timestamps - If time, then may not =, if string, then all

    Thanks, 6StringJazzer!

    Your formula works a charm!

    I really appreciate the help.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,923

    Re: Data Validation: Comparing 2 timestamps - If time, then may not =, if string, then all

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on addreputationicon.jpg below their name.

+ 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. Replies: 4
    Last Post: 10-28-2015, 12:59 PM
  2. Data validation - intgers bigger than 0 and empty cell not allowed
    By fibonacci1101 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-31-2013, 04:51 PM
  3. Time between timestamps excluding certain hours
    By Silaswulff in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-01-2011, 06:08 PM
  4. Replies: 11
    Last Post: 02-22-2011, 07:07 PM
  5. Comparing a string to values in an array resulting in a Run time Error 1004
    By sgreni in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2009, 04:21 PM
  6. comparing a phone number to an allowed list???
    By juzsp in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-20-2007, 12:00 PM
  7. Replies: 2
    Last Post: 06-16-2006, 01:15 PM

Tags for this Thread

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