+ Reply to Thread
Results 1 to 5 of 5

Vlookup function returns some #n/a

  1. #1
    Registered User
    Join Date
    02-27-2020
    Location
    Kansas, USA
    MS-Off Ver
    MS Office Pro 2016
    Posts
    1

    Vlookup function returns some #n/a

    I have some data in two columns, the first column of which are time stamps in 15 second increments. I want to create a second list that extracts some data from the second column but only those from 15 minute increments. I am using a vlookup function with Mround to extract the items, but only a few of the cells end up being populated with correct values, while the remainder show #n/a. I have formatted the time stamps with the same date formulae; further I have tested and find that the relevant time stamps being compared are equal -- see the small list comparing values. What am I missing? Thx
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Vlookup function returns some #n/a

    As soon as you use MROUND or any other Rounding function with Times. You are Screwed.


    Formula for A4 then fill down =ROUND(A$3+(0.5/60/24)*(ROW()-3),5)

    Formula for E3 Entered using Ctrl Shift Enter then fill down. =INDEX($B$3:$B$215,MATCH(TEXT(D3,"hh:mm"),TEXT($A$3:$A$214,"hh:mm"))-1,1)
    Attached Files Attached Files
    Last edited by mehmetcik; 02-28-2020 at 12:59 AM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Vlookup function returns some #n/a

    [.... deleted by me; see replacement below ....]
    Last edited by joeu2004; 02-28-2020 at 12:25 AM.

  4. #4
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Vlookup function returns some #n/a

    [Reposted with major changes]

    In general, do not use a decimal fraction in the second parameter of MROUND. Often, the result is not a binary match for the equivalent constant.

    And use some a form of --TEXT(...,"h:m") or --TEXT(...,"h:m:s") to round time calculations to the correct binary representation.

    (Use "[h]" instead of "h" if the result of the time calculation is less than 10,000 hours. That is not the case in your calculations.)


    First, change the formula in A4 to:

    =--TEXT(A3+"0:0:30","m/d/yyyy h:m:s")

    and copy down the column and format as desired.

    Note that the TEXT format is sensitive to the way that dates are represented in your region (e.g, m/d/yyyy, d/m/yyyy or yyyy/m/d). Let me know if that is unacceptable.


    Similarly, change the formula in D4 to:


    =--TEXT(D3+"0:15","m/d/yyyy h:m")

    and copy down the column and format as desired.


    Finally, change the formula in E3 to:

    =VLOOKUP(D3,$A$3:$B$215,2,FALSE)

    and copy down the column.


    -----
    In a previous posting, I offered formulas of the form =INT(A3+"0:0:30")+TEXT(A3+"0:0:30","h:m:s") as an alternative that is not sensitive to the way that dates are represented in your region.

    But I expressed some doubts about the use of INT in this context because of concerns for binary arithmetic anomalies.

    Although such potential anomalies do not apply if you follow the steps that I outline above, they might indeed arise in other time calculations. I do not want to suggest a method that works only sometimes, at least not without explaining the special circumstances.

    And as it turns, the potential problem arises in even simpler situations.

    For example, suppose that a time calculation results in 2/27/2020 23:59:59.500 in A6.

    Rounded to the minute, the correct result is 2/28/2020 0:00 (midnight), because Excel rounds time to the second when formatting "h", "h:m" and "h:m:s".

    And that is indeed the result of the formula =--TEXT(A6,"m/d/yyyy h:m:s").

    However, the formula =INT(A6)+TEXT(A6,"h:m:s") results in 2/27/2020 0:00. Obviously, that is incorrect.

    The reason for the latter result is: the decimal value of A6 is 43888.9999999999, when rounded to 15 significant decimal digits, as the INT function does. So INT(A6) correctly (but unintentionally) returns 43888, the date serial number for 2/27/2020. TEXT(A6,"h:m:s") correctly returns "0:0:0" because, again, Excel rounds time to the second in that context.
    Last edited by joeu2004; 02-28-2020 at 12:11 PM.

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,435

    Re: Vlookup function returns some #n/a

    In A3 use ROUND(formula,10)
    Please Login or Register  to view this content.
    Drag down
    same in D4:
    Please Login or Register  to view this content.
    Drag down
    Now it should works.
    Quang PT

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] IF VLOOKUP Function that returns blank cell if value is 0
    By McCaughley7 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-21-2016, 03:51 PM
  2. VBA Vlookup function returns wrong values
    By alicelia in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-29-2015, 12:09 AM
  3. VBA Function to simulate VLookUp which returns multiple
    By jackubu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-18-2013, 07:42 AM
  4. [SOLVED] Unique returns for Large Function with VLookup needed
    By James McEwan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-02-2013, 02:04 PM
  5. VLOOKUP array function returns the same column
    By murphy_sj in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-15-2012, 12:35 AM
  6. [SOLVED] VLOOKUP function returns 1/0/1900
    By kpodonnell in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-21-2012, 08:50 PM
  7. vlookup fails on data from a pivot table-function returns N/A
    By Pat in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-17-2005, 05:05 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