+ Reply to Thread
Results 1 to 14 of 14

vlookup returning 0 value when told not to

Hybrid View

  1. #1
    Registered User
    Join Date
    07-28-2010
    Location
    Chambersburg, PA, USA
    MS-Off Ver
    Excel 2010
    Posts
    39

    vlookup returning 0 value when told not to

    I've had this problem for sometime and while its not hindering me right now it does create a bit of visual confusion on the screen and when trying to distribute a report to co-workers. I've have a sheet that I use the vlookup function on and when told to display nothing in the event of an isna value it will display a 0 instead. I've attached a copy of the sheet so you can dissect as necessary. Again it references properly when data is present but not when there is an absence of data. Use column D as a reference for the error, cell D14 is the first instance of this error. I've tried different formats for the cells as well.
    Attached Files Attached Files

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: vlookup returning 0 value when told not to

    You don't have any NA on the Packet Schedule sheet, so the ISNA function is always going to return False. Instead test for blank like this:

    =IF(VLOOKUP($A14,'Packet Schedule'!$A$1:$C$498,3,FALSE)="","",VLOOKUP($A14,'Packet Schedule'!$A$1:$C$498,3,FALSE))
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    07-28-2010
    Location
    Chambersburg, PA, USA
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: vlookup returning 0 value when told not to

    Quote Originally Posted by davegugg View Post
    You don't have any NA on the Packet Schedule sheet, so the ISNA function is always going to return False. Instead test for blank like this:

    =IF(VLOOKUP($A14,'Packet Schedule'!$A$1:$C$498,3,FALSE)="","",VLOOKUP($A14,'Packet Schedule'!$A$1:$C$498,3,FALSE))
    This would work so long as I have a value in the lookup column (A). It does return an N/A value in the other cells where there is no lookup value. That's why I specified the isna portion. I suppose I'll have to just auto fill the formula if I have values in column A and leave the others blank until I have data.

  4. #4
    Registered User
    Join Date
    07-28-2010
    Location
    Chambersburg, PA, USA
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: vlookup returning 0 value when told not to

    =IF(IF(ISNA(VLOOKUP($A14,'Packet Schedule'!$A$1:$F$1000,3,FALSE)),"0",VLOOKUP($A14,'Packet Schedule'!$A$1:$F$1000,3,FALSE))="0","",VLOOKUP($A14,'Packet Schedule'!$A$1:$F$1000,3,FALSE))
    Crude but this did the trick. Any help on cleaning it up?

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: vlookup returning 0 value when told not to

    Since none of the values in the searched column are less than 4 characters would it be safe to assume that will always be the case?

    If so you could use:

    =if(LEN(VLOOKUP($A14,'Packet Schedule'!$A$1:$C$498,3,FALSE)<2,"",VLOOKUP($A14,'Packet Schedule'!$A$1:$C$498,3,FALSE))
    That will take care of 0's or blanks

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,677

    Re: vlookup returning 0 value when told not to

    You could just use your original formula with &"" appended to the second VLOOKUP, that will suppress the zeroes, i.e.

    =IF(ISNA(VLOOKUP($A2,'Packet Schedule'!$A$2:$E$599,5,FALSE)),"",VLOOKUP($A2,'Packet Schedule'!$A$2:$E$599,5,FALSE)&"")
    Audere est facere

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: vlookup returning 0 value when told not to

    Your zeros are not coming from the ISNA portion of your equation but from the vlookup when you find something in column A (the id is on your packet schedule) but there's nothing to return in column 3. You'll need to nest a second IF statement to return "" if VLOOKUP returns 0 or set up your options to not show zeros. Hope that helps.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  8. #8
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: vlookup returning 0 value when told not to

    The prob is not in the formula, it is because on you packet schedule for items 759142 and 759144 and many others you have nothing under column 3 (or C) as instructed by your vlookup formula, so you need to enter something in that column so that it returns something else other than 0, or an addtional IF argument.

    EDIT: Hey! I'm late for the party
    Ron
    Knowledge is knowing that a tomato and pepper are fruits. Wisdom is knowing whether to put these in a fruit salad

    Kindly

    [1] Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks
    [2] Mark your post [SOLVED] if it has been answered satisfactorily by editing your original post in advanced mode.
    [3] Thank (using the little scale) those that provided useful help; its nice and its very well appreciated

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: vlookup returning 0 value when told not to

    If you highlight the vlookup portion of your formula and hit F9 you'll see that it equates to 0 so the ISNA will not kick in. To allow for a 0 value use:

    =IF(OR(ISNA(VLOOKUP($A14,'Packet Schedule'!$A$1:$C$498,3,FALSE)),VLOOKUP($A14,'Packet Schedule'!$A$1:$C$498,3,FALSE)=0),"",VLOOKUP($A14,'Packet Schedule'!$A$1:$C$498,3,FALSE))

  10. #10
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: vlookup returning 0 value when told not to

    Look at Cutter's response, he fixed my oversight on that issue.

+ 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