+ Reply to Thread
Results 1 to 12 of 12

One vlookup returns correct value, next does not

  1. #1
    Registered User
    Join Date
    03-26-2009
    Location
    Johnstown, Colorado
    MS-Off Ver
    Excel 2003
    Posts
    3

    One vlookup returns correct value, next does not

    Hi All,

    Looking for some help to figure out what is causing our problem. My friend has created the attached excel sheet in Excel 2003. The issue is that the a vlookup does not seem to be finding the correct line for the value from the lookup table when it is returned twice.

    Let me explain - The details are contained in the attached workbook. There are three sheets in the workbook - NH3Curve, Samples and Qvalue table.

    On the Samples sheet, in cell C12 and C13 you can enter varying values. Go across to F12 and F13 and you will see that they both have the value 22.1. This is where the issue occurs - in cells G12 and G13 the lookup value should be the same - but it is not. G12 is actually returning the value for 22.0 not 22.1. (lines 173 and 174 on the Qvalue sheet). We cannot ferret out why this is happening.

    Any help would be greatly appreciated. Sometimes when you look at something you can't see the obvious, so I hope it is that simple.

    I have not cross-posted this topic anywhere else.

    Thanks for your time.
    Attached Files Attached Files
    Last edited by techgal; 03-26-2009 at 10:55 PM. Reason: Solved

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: One vlookup returns correct value, next does not

    Hi,

    go Tools - Options - Calculation and tick "Precision as displayed". This will now show a warning box, but from then on the sheet will only calculate visible values, i.e. if you have formatted a number to show 2 decimals, it will do all follow on calculations with only the two decimals, not accounting for the hidden decimals.

    I still don't understand why this solves the problem, because the calculations leading to your value of 22.1 are straightforward and do not contain any decimals that might upset the picture. As far as I see it, Excel is indeed showing the wrong value, but I'll keep looking as to why.

    stumped ....

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: One vlookup returns correct value, next does not

    Hi,
    this is really weird.
    If you change the lookup formula's last value to FALSE, Excel will return only an exact match. And it seems that the 22.1 that results from

    =ABS(C12-D12)

    which is 89-66.9 is not the same as the 22.1 that is in your lookup table. It seems to be a teeeny tiiiiiny bit smaller than 22.1, but no matter how many decimals I display, I don't see where. Other than setting precision to "as displayed", as I said above, you could round the value as in

    =ROUND(ABS(C12-D12),1)

    This will effectively cut off any further decimals and the Lookup will work as expected.

    I've started a brand new Excel sheet and done the same kind of calculations and lookups. If I use 89 minus 66.9 it will not find it, if I use 23.1 minus 1 it will find it without a hitch.

    Still stumped.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: One vlookup returns correct value, next does not

    When I run the evaluator on the formula:

    =INT(F13)+MOD(F13,1)

    ...and then run it on:

    INT(F12)+MOD(F12,1)

    ...the MOD section for the decimals clearly shows the variance. One is .10000000009 and the other is .09999999993

    I guess that's not a match.

    Worse, when I run it on the Qvalue page

    =INT(A174)+MOD(A174,1)

    .....it returns a decimal value of 1.00000000001

    That's three different versions of the same number.
    Last edited by JBeaucaire; 03-26-2009 at 09:27 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: One vlookup returns correct value, next does not

    Teylyn is on the mark with this.

    McGimpsey & Associates has an article describing this topic here: Penny Off

    .
    Last edited by ConneXionLost; 03-26-2009 at 09:34 PM.
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: One vlookup returns correct value, next does not

    JB, good spotting. Can you please try to explain to me why

    89-66.9

    returns a different flavour of 22.1

    than, say

    23.1-1

    I attach a spreadsheet with a demonstration how some values of 22.1 are found by the Vlookup, others are not. Apparently 86-63.9 returns a different kind of 22.1 (found by Vlookup) than 87-64.9 (not found by Vlookup).

    I think this is clearly a problem with Excel. I look at the spreadsheet and think "Wow. I wonder how many other similar things are happening in Excel, that I have just not spotted yet!?"
    Attached Files Attached Files

  7. #7
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: One vlookup returns correct value, next does not

    ConnexionLost, thanks for that article. Funny thing is that there are no decimals that are formatted away. Take a look at the spreasheet in my previous post and see what I mean.

  8. #8
    Registered User
    Join Date
    03-26-2009
    Location
    Johnstown, Colorado
    MS-Off Ver
    Excel 2003
    Posts
    3

    Thumbs up Re: One vlookup returns correct value, next does not

    Wow, that was quick - ALL of you are awesome. I appreciate the brain power puzzling over these issues.

    I did try Teylyn's solution and it does work for our workbook, as I'm sure it will for some others that have been created on this model. While I did say that it was created in 2003, I forgot to mention that I am viewing it in 2007. However, I figured out where to turn precision on in 2007 (Excel Options button\Advanced\When calculating this workbook) and it also works for getting the correct solution in 2007. We expect end users to put in their data on the sheet and we wanted to make sure that they were getting the correct output.

    I will read more about the "precision" setup and pass that on to the creator of the workbook, too. I am also going to have him sign up for this forum, because I know he will appreciate what all of you do to help those of us not in the know. And to find more answers.

    As I am not totally familiar with the customs of this forum yet, if I need to do anything else in regard to this post let me know.

    Really AWESOME help. Again, thanks so much!

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: One vlookup returns correct value, next does not

    You should mark the thread as solved if you're happy with the solution. You need to edit the thread and look near the title where only you can see a drop down box to select "Solved".

    You can also add to someone's reputation if you liked an answer specifically. On the post that you found helpful, click the scale symbol and follow your gut ...

  10. #10
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: One vlookup returns correct value, next does not

    Please mark your thread solved by doing the following:

    - Go to the first post
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix. - Change to Solve
    - Click Save

  11. #11
    Registered User
    Join Date
    03-26-2009
    Location
    Johnstown, Colorado
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: One vlookup returns correct value, next does not

    Thanks for the etiquette tips. I have marked it as solved.

    Thanks, Teylyn. I hope your reputation continues to grow!

  12. #12
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: One vlookup returns correct value, next does not

    Floating points in Excel. Did some more research and some experiements.

    MOD(1.9,1) returns 0.9. Fine. Looks good. Same for increments of 1.0 from
    MOD(2.9,1) through to MOD(15.9,1). But then it's
    MOD(16.9,1) which returns 0.8999999999999990000000
    MOD(17.8,1) incrementing by 1 through to MOD(63.9,1) the same. Then the next break at
    MOD(64.9,1) which returns 0.9000000000000060000000
    The next break is at
    MOD(256.9,1) which returns 0.8999999999999770000000
    See the pattern?

    The funny thing is that if you compare the 22.1 values from the OP's example

    =F12=F13

    Excel returns TRUE. As does the comparison

    =F12='Qvalue table'!A174
    and
    =F13='Qvalue table'!A174

    All these return TRUE. But VLOOKUP apparently sees this differently.

+ 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