+ Reply to Thread
Results 1 to 7 of 7

How to compare dates

Hybrid View

  1. #1
    Registered User
    Join Date
    11-21-2008
    Location
    India
    Posts
    6

    How to compare dates

    I have dates in col A and Col B. I want to match the col A dates with Col B and want to have the dates which matches.

    for eg
    A B C
    15/2/2009 15/2/2009 Y
    25/2/2009 26/2/2009 N
    5/2/2009 26/2/2009 N

    Please reply & thanks in advance.

  2. #2
    Forum Contributor
    Join Date
    04-23-2009
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003 work, 2007 home
    Posts
    199

    Re: How to compare dates

    Hi

    in column C1 use formula =IF(A1=B1,"Y","N") to return a Y value for matches and an N value for non-matches, drag formula down as far as cells A & B are populated

  3. #3
    Registered User
    Join Date
    11-21-2008
    Location
    India
    Posts
    6

    Re: How to compare dates

    I think should better post the ques as...

    I need to match A1 with the entire B column and not only with the adjacent value.

    Please help me resolving this.

    Thanks for answering.

  4. #4
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: How to compare dates

    Try this

    ={IF(EXACT(A1,B1:B26),"Y","N")}


    Confirm w/ ctrl+shift+enter
    Maybe it will help
    Attached Files Attached Files
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How to compare dates

    poojabans , perhaps you should post a workbook and explain what you want in context.

    ContaminatedWitExcel, EXACT only serves to make Excel do case-sensitive compares, and is not relevant to numbers.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Contributor
    Join Date
    04-23-2009
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003 work, 2007 home
    Posts
    199

    Re: How to compare dates

    ok you will need a vlookup then eg =VLOOKUP(A:A,B:B,1,FALSE) where cell C will return an #N/A where it doesn't recognise the date in column A anywhere in column B and a date value where it recognises across both columns. you can then change all #N/A values to "N" and all else to "Y"

    there's probably way fancier ways our there though- that's my quick solution, hope it helps

  7. #7
    Forum Contributor
    Join Date
    04-23-2009
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2003 work, 2007 home
    Posts
    199

    Re: How to compare dates

    Here’s something I ran up if I understand correctly what you want this will do what I suggested earlier but take the manual right out. Macro- Record Macro- Stop straight away and paste the code in in place of what was recorded- close and hit macro- run. This assumes that your data compares A&B in C and that the worksheet is called "Sheet1" (if not change to whatever you have it called on line 2)

    
    Sub DateCompare()
    
    Sheets("Sheet1").Select
    Range("C1").Select
        Do While IsEmpty(ActiveCell.Offset(0, -1)) = False
        ActiveCell.FormulaR1C1 = "=VLOOKUP(C[-2],C[-1],1,0)"
        ActiveCell.Offset(1, 0).Select
        Loop
    
        Range("D1").Select
           Do While IsEmpty(ActiveCell.Offset(0, -1)) = False
        ActiveCell.FormulaR1C1 = "=IF(RC[-1]=""#N/A"",""N"",""Y"")"
        ActiveCell.Offset(1, 0).Select
        Loop
         Columns("D:D").Select
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Selection.Replace What:="#N/A", Replacement:="N", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
                Columns("C:C").Select
        Selection.Delete Shift:=xlToLeft
    
    End Sub
    Last edited by somesoldiers; 05-18-2009 at 12:15 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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