+ Reply to Thread
Results 1 to 4 of 4

compare time values - current time with time in cell range?

  1. #1
    Registered User
    Join Date
    09-11-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    23

    compare time values - current time with time in cell range?

    I have a time in a cell that might be one of a few times, like 10:30 or 18:30 or 02:30. I need to write an if statement that returns true if the current time on the computer is within 2 hours of the time in the cell (so for 18:30, it returns true if its 16:30 to 18:29), otherwise just returns false. I'm getting confused with the logic cause i know i should be subtracting 2 hrs from the time in the cell, but having trouble with math operations on time values...

    the cell will always be in the format 00:00 (military time?), any ideas how to do this?

    Wyatt...

  2. #2
    Registered User
    Join Date
    09-11-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: compare time values - current time with time in cell range?

    just to give an idea of how i'm trying to figure it out (in formula),

    Please Login or Register  to view this content.
    apparently you can't have a negative time value, so i'm going the other way, but like i said, it seems like i'm going in circles... but above gives error.

    Wyatt...

  3. #3
    Registered User
    Join Date
    09-11-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: compare time values - current time with time in cell range?

    i'm very close, but the logic is eluding me...seems =a1-2 just returns ###### so I need to figure out how to subtract 2 hours from value in A1 (-2 doesn't work)

    Please Login or Register  to view this content.
    Anyone have an idea? I'm tried searching but its usually examples subtracting 2 time values...

  4. #4
    Registered User
    Join Date
    09-11-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: compare time values - current time with time in cell range?

    Ok, I got an AND statement working to return true/false:
    Please Login or Register  to view this content.
    I put 02:00 in I5 as a workaround since i couldn't subtract 02:00 directly. Now, I have a column of times that I want to check it against with conditional formatting (if return is true, a cell on same row is filled in yellow). The code above returns true, but how do I check against all cells in a given column?

    I was able to do it with a countif:

    Please Login or Register  to view this content.
    which checked all rows in C against all rows in column I ($I7), but how would i check every time in a column and if true, highlight a cell in the same row 5 columns over?

+ 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: 5
    Last Post: 04-18-2013, 11:31 AM
  2. Display the date and time each time the data in a cell range is changed
    By BVZM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-24-2012, 01:23 PM
  3. Replies: 0
    Last Post: 05-18-2012, 04:42 AM
  4. macro to compare time between two cells if time matches output in third cell
    By kshitij_dch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2012, 07:09 AM
  5. Re: On select cell enter current time (range A1:A999)
    By Cheekybeelzebub in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2009, 05:03 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