Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6768231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:03:03+00:00 2026-05-26T15:03:03+00:00

I am trying to compare the dates with time from inside a cell with

  • 0

I am trying to compare the dates with time from inside a cell with Now()

I have the code so the style sheet autorefresh itself so when first date with time is overdue cell go green and when the second date and time is overdue the cell would go red.

I can only get this to work comparing the date without the time with DateValue.

There is a colunm with cells with two dates with times mayorly (sometimes there is only 1 date and sometimes there is only one date without time)

Cells with two dates with time would be as the example below.

-----------------
12/11/2011 09:00
13/11/2011 15:00
-----------------

This is what I have so far after several attempts (cosidering that many of the attemps have been deleted already)

Sub Worksheet_Change()

 Set aWorkBook = Workbooks("Workbook.xls").Sheets("sheet 2").Range("C3:C10")


    For Each Cell In aWorkBook
    'MsgBox (Mid(Cell.Value, 1, 19))
    If Cell.Value <> "" Then
    MsgBox (Now < Mid(Cell.Value, 11, 6))
    'MsgBox ((Mid(Cell.Value, 1, 17)) < Now())
    'MsgBox ((Cell.Value))

        If (CDate(Mid(Cell.Value, 1, 17)) < Now()) Then
              'MsgBox ("Hello")
              'Cell.Interior.ColorIndex = 3
          End If

       End If
    Next
End Sub

In this case I am using msgbox to test outcome but not success.

Any help would be very much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:03:03+00:00Added an answer on May 26, 2026 at 3:03 pm

    Looking at your code it apears the date/time values are strings. If thats the case use

    (DateValue(Cell) + TimeValue(Cell)) > Now()
    

    If cells contain values formatted as dates, use

    Cell > Now()
    

    You might be better off using Conditional Formatting rather than the _Change event. Eg to format cell A3 use conditional formula (note, no $‘s)

    (DateValue(A3) + TimeValue(A3)) > Now()
    

    then copy paste formats to any other cells you want

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to compare two dates. I have this code which I thought
I'm trying to compare a GMT time offset from the operating system to a
I am trying to compare two decimal values in Java script. I have two
I am trying to compare two text files and output the first string in
I am trying to compare the value of 2 instances of x inside an
I have problems comparing the datetime property of objects and when trying to compare
I am trying to test the API from ankoder.com and have problem on the
I am having a problem when i am trying to compare two dates in
Hi im trying to compare two dates in MySQL via a query, one is
I have the following problem. I am trying to compare two datetime values in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.