+ Reply to Thread
Results 1 to 9 of 9

Hlookup function returns 0 when there is no value!

  1. #1
    Registered User
    Join Date
    05-17-2010
    Location
    toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    24

    Hlookup function returns 0 when there is no value!

    Hello community!

    I have a lot of hlookup functions that are linking to another sheet.
    the problem is when there is nothing entered in the cell, it returns a 0 value instead of just blank.

    I need to distinguish between a real 0 and the virtual 0 that is returned when the cell is empty, therefore i can NOT use something like:

    Please Login or Register  to view this content.
    help?
    Last edited by telnoman; 05-27-2010 at 01:42 PM.

  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

    Re: Hlookup function returns 0 when there is no value!

    I use the LEN() function to test the length of the result to determine if it's a blank cell or a cell with a zero in it.

    If my original formala were:
    =VLOOKUP("Joe", A1:E11, 5, 0)
    ...and that gave me zeros for both empty cells AND for cells with actual zeros in them, I would change it to:
    =IF(LEN(VLOOKUP("Joe", A1:E11, 5, 0))=0, "", VLOOKUP("Joe", A1:E11, 5, 0))
    _________________
    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
    Registered User
    Join Date
    05-17-2010
    Location
    toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Hlookup function returns 0 when there is no value!

    good idea!
    that does work, but would be very tedious in my case, because there are several hlookups that refer to each other.

    For example Workbook 1 has a value "" (blank), workbook 2 uses hlookup to get value "" (in form of zero), and workbook 3 uses hlookup to get value "0" from workbook 2!
    so I would have to use the LEN() function in both workbooks!

    I think your solution is the only one though, so thanks a million for it!

  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: Hlookup function returns 0 when there is no value!

    It should only be tedious the first time, then it's done...

    =======
    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  5. #5
    Registered User
    Join Date
    05-17-2010
    Location
    toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Hlookup function returns 0 when there is no value!

    I found a stupid solution...
    I just put a (') apostrophe in any cell I want to have blank!
    and the hlookup functions work fine with that, they return a blank cell

  6. #6
    Registered User
    Join Date
    06-26-2011
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Hlookup function returns 0 when there is no value!

    Brilliant solution telnonman, and it works better with Conditional Formatting
    Many thanks

  7. #7
    Registered User
    Join Date
    10-03-2013
    Location
    Michigan, USA
    MS-Off Ver
    O365 Insider (Beta Channel)
    Posts
    8

    Re: Hlookup function returns 0 when there is no value!

    Extremely old topic, sorry for the response.
    For my file, I wanted to highlight cell values above 15 to be red color. However, all cells have hlookup therefore even the cells with hlookup returning nothing got highlighted red.
    Following the idea on this thread, I placed the len(D5)=0 to highlight "blank" cells with no color. This resolved my problem. I prefer this method rather than putting (') as that messes other things up in my file.
    Wanted to share for those who search for similar solutions..

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,755

    Re: Hlookup function returns 0 when there is no value!

    Welcome to the forum!

    Unfortunately your post does not comply with Rule 4 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Hlookup function returns 0 when there is no value!

    @ AliGW,

    The OP was not looking for a solution, but merely shared an alternative solution to an old thread.

    I honestly feel that this Post of the OP in this old thread, bears valuable information.

    Granted. The OP could also have started a new Thread and provided a link to this thread, but would that not be cumbersome?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

+ 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