+ Reply to Thread
Results 1 to 15 of 15

Basic VLookup function doesn't work in large data set from msquery

  1. #1
    Registered User
    Join Date
    09-16-2008
    Location
    Los angeles
    Posts
    17

    Basic VLookup function doesn't work in large data set from msquery

    I'm trying to use a basic formula, but it returns an N/A

    =VLOOKUP(F12,A2:B999,2, TRUE)

    However, it works if I plug in the value manually

    =VLOOKUP("4000000", A2:B999,2,FALSE)


    Why is this, and how can i fix it?

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    It works when I try it. Can you post some sample data so we can see the error in action?
    Attached Files Attached Files
    Last edited by JBeaucaire; 11-10-2008 at 09:21 PM. Reason: added a workbook sample
    _________________
    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!)

  3. #3
    Forum Contributor EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    Why are you using TRUE as your final parameter? False is usually better as it can cope with unsorted data.
    Ed
    _____________________________
    Always learning, but never enough!
    _____________________________

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Quote Originally Posted by eldoradotower View Post
    I'm trying to use a basic formula, but it returns an N/A

    =VLOOKUP(F12,A2:B999,2, TRUE)

    However, it works if I plug in the value manually

    =VLOOKUP("4000000", A2:B999,2,FALSE)


    Why is this, and how can i fix it?
    Could it be that values in the second column of A2:b999 are text strings looking as numbers, rather than numbers
    If so you might try =VLOOKUP(F12&"",$A$2:$B$999,2, false)
    ( Using False as EdMac suggests)
    Adding a sample of your data as an xls file will give a clearer view on your problem

  5. #5
    Forum Contributor EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    As Arthur says, it looks like the numbers are, actually, text values - the fact that you have put " " around the lookup value would seem to confirm this.

    Take the speech marks out and see what happens - if it fails than this is your problem. Keep the last parameter as false as previously advised.

    Post a copy of your sheet and then it can be looked at in detail.

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    http://www.contextures.com/xlFunctions02.html
    gives some good examples of troubleshooting vlookup for future reference

  7. #7
    Registered User
    Join Date
    09-16-2008
    Location
    Los angeles
    Posts
    17
    ok thanks guys, it worked...i need to sum the columns but when i drag down the formula the cells don't change

    =IF(ISNA(VLOOKUP(F13&"",A3:B1000,2,FALSE)),0,VLOOKUP(F13&"",A3:B1000,2, FALSE))

    is it possible to make the above formula change appropriately when dragged down?

  8. #8
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Could you post a sample of your data as already asked? This would be helpful Thx

  9. #9
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324
    You need to change the cell references to absolute references so that they do not change when you drag them down.

  10. #10
    Registered User
    Join Date
    09-16-2008
    Location
    Los angeles
    Posts
    17
    Quote Originally Posted by dcgrove View Post
    You need to change the cell references to absolute references so that they do not change when you drag them down.
    I DO want the cells to change. And I can't really post sample data because its all financial information from an ms query.

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Do you mean the references don't change or that the result is not changing?

    If the latter, than go to Tools|Options and from the Calculation tab, select Automatic calculation.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  12. #12
    Registered User
    Join Date
    09-16-2008
    Location
    Los angeles
    Posts
    17
    Quote Originally Posted by NBVC View Post
    Do you mean the references don't change or that the result is not changing?

    If the latter, than go to Tools|Options and from the Calculation tab, select Automatic calculation.
    the references

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    works ok for me dragged down looks like this
    Please Login or Register  to view this content.
    you should fix the $A$3:$B$1000 absolutely as the referenced table is not changing but f13 goes to f14 and so on

  14. #14
    Registered User
    Join Date
    09-16-2008
    Location
    Los angeles
    Posts
    17
    thanks! please mark thread solved

  15. #15
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    You can do this yourself.
    Please edit your first post - Click "Go advanced" and modify the prefix of your title

+ 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