Results 1 to 6 of 6

Comparing dates does not work

Threaded View

  1. #1
    Registered User
    Join Date
    05-25-2017
    Location
    Buchs, Switzlerand
    MS-Off Ver
    2019
    Posts
    75

    Comparing dates does not work

    Hello,

    In a code, I compare the dates of a master File with those of a target file to determine where the last entry has been made. The code reliably conducts the comparison of Cell B37 of the target file with cell A12 of the master cell. For some reason, however, the code does not recognize when the dates are the same.

    The relevant part of the VBA:
    In the target file, "Date_new" gives me the last entry (January 6, 2023), which in this case is in cell B37:

    DATE_new = ActiveCell.Value

    Switching over to the master file...

    Windows("Current_Market_Data_Europe_extract_comparing dates_Master.xlsm").Activate

    That date is to be found in a table:
    If Cells(i, 1).Value = DATE_new And Cells(i + 1, 1).Value <> "" Then

    N.B. A "For...Next" loop relaibly leads to a value where cells(12,1).Value is addressed, i.e. the cell in the master file containing the entry "Jan. 6, 2023".
    Problem: The comparison doesn't work, despite the dates being the same (January 6, 2023), including the formatting. Even when I make a direct comparion in Excel (see Master file cell G25), the statement that they are equal gives me a "false". Why are the two dates with the same formatting regarded as not being the same?

    Excel_Arate

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Comparing due dates vs. completion dates, with more than 2 outcomes
    By excel party in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-12-2020, 12:21 AM
  2. [SOLVED] Formating custom dates and comparing dates with different formats
    By OmniBlue in forum Excel General
    Replies: 2
    Last Post: 01-09-2014, 10:08 AM
  3. Comparing Two Work Sheets
    By akbar in forum Excel General
    Replies: 1
    Last Post: 01-15-2013, 12:07 AM
  4. [SOLVED] comparing two work books
    By sqlindia in forum Excel General
    Replies: 4
    Last Post: 07-22-2012, 10:54 AM
  5. Replies: 5
    Last Post: 06-24-2010, 06:21 AM
  6. Comparing Dates does not work properly
    By JMP86 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-03-2009, 04:58 AM
  7. Replies: 0
    Last Post: 12-19-2005, 07:45 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