+ Reply to Thread
Results 1 to 16 of 16

issue finding a date in vlookup

  1. #1
    Registered User
    Join Date
    01-06-2013
    Location
    Sacramento,CA
    MS-Off Ver
    2013
    Posts
    36

    issue finding a date in vlookup

    Members,

    what should be a simple vlookup is driving me nuts. I have a field for a date and time input that i want to search for in a column of dates and time. Both the input entry cell and the search cells are formatted as yyyy/mm/dd hh:mm:ss and there are no blank cell in the column of dates/time

    A B C D

    Date/Time Open High (input field 2013/2/15 15:30:00
    2013/2/15 17:00:00 1517.25 1517.75
    2013/2/15 16:45:00 1517.25 1517.5
    2013/2/15 16:30:00 1516.75 1517.5
    2013/2/15 16:00:00 1517.25 1518.5
    2013/2/15 15:45:00 1516.5 1517.5
    2013/2/15 15:30:00 1514.75 1516.5 **********
    2013/2/15 15:15:00 1513 1515
    2013/2/15 15:00:00 1512.5 1514

    formula: =Vlookup(D1,A1:C9,3,false) This should return a value of 1516.5, correct?

    However, all I get in the formula cell is #N/A Am I doing it correctly or is there a better way?

    Any assistance wil lbe greatly appreciated. Thanks!
    Last edited by Araise; 02-17-2013 at 07:23 PM.

  2. #2
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: issue finding a date in vlookup

    My guess would be that the values are slightly different...check for leading, trailing spaces, dates/times are dates/times, etc...
    The #N/A means it did not find a match, so I would think even Match() would return a similar result for you..
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  3. #3
    Registered User
    Join Date
    01-06-2013
    Location
    Sacramento,CA
    MS-Off Ver
    2013
    Posts
    36

    Re: issue finding a date in vlookup

    Dredwolf, that's initially what I thought as well, so I made sure the formatting of the input date and the date/time columns are identical. I even went so far as to change the date/time to "general" in both fields - result still the same.

  4. #4
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: issue finding a date in vlookup

    Could you upload a sample to look at?..very hard to picture the data in your OP

  5. #5
    Registered User
    Join Date
    01-06-2013
    Location
    Sacramento,CA
    MS-Off Ver
    2013
    Posts
    36

    Re: issue finding a date in vlookup

    attaching a file
    Attached Files Attached Files

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

    Re: issue finding a date in vlookup

    its to do with rounding try array entered
    =VLOOKUP(ROUND(F2,6),ROUND(A3:C34,6),3,FALSE)
    "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

  7. #7
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: issue finding a date in vlookup

    Okay, I see what the problem is, just trying to figure out a solution..
    The problem is round-off error at the bottom end of the time code..your value in f2 rounds off to 7 at 10th decimal, the matching value rounds off to 6 at tenth decimal.. will keep working on it

  8. #8
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: issue finding a date in vlookup

    Or, use martins solution ...lol

  9. #9
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: issue finding a date in vlookup

    Alternative solution, regular formula :
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This does basically the same thing as Martin's though, so either one should work for you

  10. #10
    Registered User
    Join Date
    01-06-2013
    Location
    Sacramento,CA
    MS-Off Ver
    2013
    Posts
    36

    Re: issue finding a date in vlookup

    Thx to both, Martin's gave me a #VALUE! error and the index gave me a value of1516.75 when the correct value should be 1520.5

    It's nuts isn't it? I'll fiddle with the rounding situation and see if can get them to agree

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

    Re: issue finding a date in vlookup

    a did you array enter it with ctrl+shift+enter?
    http://office.microsoft.com/en-us/ex...872901033.aspx

  12. #12
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: issue finding a date in vlookup

    Returns the proper result for me???
    Not sure why you are getting wrong value...
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    01-06-2013
    Location
    Sacramento,CA
    MS-Off Ver
    2013
    Posts
    36

    Re: issue finding a date in vlookup

    Martin - of course not !!! now it's working. Need to smack myself on the head fo that mistake. Thanks again to all ! problem solved!!!

  14. #14
    Registered User
    Join Date
    01-06-2013
    Location
    Sacramento,CA
    MS-Off Ver
    2013
    Posts
    36

    Re: issue finding a date in vlookup

    gents, one last thing, the vlookup array method works, but only if I convert the dates to a number andround to 6. If I try the straight date and time input, i get the #NA, so ther error rounding evidently does not work well when rounding date/time.

    Not a big deal, I'll just make a duplicate column of the dates changed to numbers and run it then. Thanks again

  15. #15
    Registered User
    Join Date
    01-06-2013
    Location
    Sacramento,CA
    MS-Off Ver
    2013
    Posts
    36

    Re: issue finding a date in vlookup

    i take it back, now it's working with the straight date/time input ---- must have a gremlin. But it works.

  16. #16
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: issue finding a date in vlookup

    You are welcome, and thanks for the rep

    And that is what both Martin and I said, the issue is the rounding error, it is (basically) caused by trying to store a decimal number(or 'real' number) into a binary format...

+ 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