+ Reply to Thread
Results 1 to 8 of 8

Vlookup on dates

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    41

    Vlookup on dates

    Hi,

    I've got a whole load of prices showing against dates and times in the format '03/01/2005 07:44:59'. I'm trying to use a vlookup on a different sheet to look up certain date and time combinations and return the price in the next column. e.g. =VLOOKUP((C11+$G$1),'Cleaned GLN'!$A$2:$E$169250,5,FALSE)

    C11 has '03/01/2005' in it and G11 has '07:44:59'.

    When i enter the above formula i just get #NA. When i try changing the 'false' to 'true' i get the previous row's price....

    Any ideas?

    Thanks very much
    Jo

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: Vlookup on dates

    You will get #N/A if there is no exact match (because your 4th parameter for VLOOKUP is set to FALSE), so are you sure that those values are EXACTLY the same? Try setting the format on the cell that you think it matches with to dd/mm/yyyy hh:mm:ss.000 (which will show fractions of a second), and set the format of G11 to hh:mm:ss.000 and see if they are the same.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    07-30-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Vlookup on dates

    Thanks. I've checked that - they are formatted exactly the same...

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: Vlookup on dates

    I didn't ask you to check the format - change the format on both so that you have .000 after the :ss, and then see if they show the same values to 1/1000ths of a second.

    Pete

  5. #5
    Registered User
    Join Date
    07-30-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Vlookup on dates

    Yep, done that. Both showing exactly the same. (i.e. now showing 03/01/2005 07:44:59.000)

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: Vlookup on dates

    Well, they are obviously not matching, so there must still be some very slight difference. I don't think Excel guarantees anything less than 1/1000th of a second, so it might be that you have differences of that small order. On your Cleaned GLN sheet you could think about applying Excel's 'Precision as Displayed' feature once the data is displaying in the format that you wish - note, though, that this is not something that you can undo, so ensure that you do it on a copy of your workbook.

    Hope this helps.

    Pete

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Vlookup on dates

    it try looking to more decimal places sometimes even if it looks the same after 15 places they may not match
    or try looking both up as convert to text then back(rounding doesnt always work either)
    add a helper and look up in that

    =TEXT(a2,"dd/mm/yyyy hh:mm:ss")+0
    Last edited by martindwilson; 07-31-2012 at 03:49 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  8. #8
    Registered User
    Join Date
    07-30-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Vlookup on dates

    Thank you thank you thank you! That = text thing worked.

    It was driving me mad...

    Thanks
    Jo

+ 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