+ Reply to Thread
Results 1 to 11 of 11

Difference Between Two Dates/Times In Two Cells

  1. #1
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Difference Between Two Dates/Times In Two Cells

    The attached shows a DEADLINE Date/Time in Column D. The current Date/Time is displayed in Column E and is counting down to the Date/Time in Column D.

    What I've tried to accomplish with a formula is a notification in Column F, when D & E equal one another (the count down has reach the end).

    Ultimately, I'd like to call a macro that will display a Userform and for the corresponding row of F to be highlighted with a color.

    I've tried using various formula formats " =IF(D1=E1,"Message","") ", =TIMEVALUE and =DATEVALUE. I've done alot of searching on the net ... haven't found anything that helps.

    If this can be accomplished with a formula or a macro or both ... would be great.

    Your assistance is greatly appreciated ! Thank you.
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Difference Between Two Dates/Times In Two Cells

    1 problem I see right away is that D has 2016 dates, but E has 1900 dates, so they will never be =. What exactly needs to be equal there, the date or the time or both?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Difference Between Two Dates/Times In Two Cells

    Both.

    I had both columns formatted the same but the dates were being displayed differently.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: Difference Between Two Dates/Times In Two Cells

    They'll never be equal. Once the timer runs out, it'll read zero. So the formula you need will be based on =if(E2=0,"Too late","Still OK")

    I don't know enough about VBA... Can your code run into the negative??? If so you might need to modify the formula.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Difference Between Two Dates/Times In Two Cells

    The countdown timer continues running past the "zero" time. I'll scratch my head some more on this one. I'm agreeable to modifying the entire setup if you have any ideas ... just so long as the result is the same.

    (See ... I'm not picky )

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Difference Between Two Dates/Times In Two Cells

    ***** Bump ******

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: Difference Between Two Dates/Times In Two Cells

    I'm no good with VBA...

    This formula in E2, copied down:

    =IF(D2-NOW()<0,0,D2-NOW())

    will stop the timer at 0. You can then use CF to make the cell shhow red when the timer reaches zero (as in the sheet). can you translate the formula into VBA-speak; or are you OK to F9 it to refresh it??
    Attached Files Attached Files

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Difference Between Two Dates/Times In Two Cells

    Glenn:

    Thank you ... the formula runs great, stopping the count down when it matches the target date/time.

    I've tried using the following in F2 to fire off a visual notice that I can work with but its not doing what I expected:
    Please Login or Register  to view this content.
    I've also tried
    Please Login or Register  to view this content.
    and a few other variations ... no good. Maybe I need to do something with VBA for this portion ?

    Any suggestions for this ?

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: Difference Between Two Dates/Times In Two Cells

    I think we're talking a slightly different language here. VBA (you) vs formula (me). when the time difference between Dx and now = 0, then Ex will shade red, in my effort. Otherwise cell Ex will stay unfilled.

  10. #10
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Difference Between Two Dates/Times In Two Cells

    Sorry .... I didn't think to look if Conditional Formatting had been applied. Now I see what you did. On my end the cell does not turn Red when it reaches 0.

    See attached. Did I do something wrong ?
    Attached Files Attached Files

  11. #11
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Difference Between Two Dates/Times In Two Cells

    Hey Glenn ...

    I did conditional formatting on F2 and the coloring of cell works like a charm. Previously, the conditional formatting was in E2 and that was not firing.

    Thanks ... got it figured out now.

    Cheers !

+ 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] Finding the difference between two dates and times
    By Harper95th in forum Excel General
    Replies: 8
    Last Post: 02-14-2014, 02:53 PM
  2. Need difference between two dates/times in hours
    By ramsdesk in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-25-2013, 01:25 PM
  3. Need to Calculate difference between 2 dates with times
    By KeithMark63 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-26-2012, 03:06 PM
  4. [SOLVED] Difference in dates calculations except between certain times.
    By Steve Hud in forum Excel General
    Replies: 1
    Last Post: 01-13-2006, 09:15 AM
  5. how do I calculate difference between two dates and times
    By PatCN in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2005, 12:20 PM
  6. [SOLVED] Difference between 2 times and dates
    By Stefan Buijs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2005, 05:19 PM
  7. [SOLVED] Difference between 2 times and dates
    By Stefan Buijs in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-26-2005, 05:15 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