+ Reply to Thread
Results 1 to 8 of 8

If a Value Doesn't Exist in a Table, Return ""

  1. #1
    Forum Contributor
    Join Date
    05-29-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    2021
    Posts
    205

    If a Value Doesn't Exist in a Table, Return ""

    I'm using the following formula:

    =INDEX($B$2:$B$251,MATCH(TRUE,INDEX(ISNUMBER(SEARCH($A$2:$A$251,H2)),0),0))

    If the value is present within column H and A, then it returns the corresponding value from column B. But if there's no match between columns B and H, I get a value of "0". How can I get a value of "" instead of "0" when there's no match?

    Thanks!
    Attached Files Attached Files
    Last edited by Ocean Zhang; 06-23-2011 at 04:13 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,469

    Re: If a Value Doesn't Exist in a Table, Return ""

    That looks quite a complex way of doing an INDEX/MATCH.

    It might help if you posted a sample workbook so that the formula can be seen in context.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    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: If a Value Doesn't Exist in a Table, Return ""

    There are three ways to do it, in order of efficiency:

    1. Select the range in which that formula exists and then, right-click|Format Cells|Number Tab| Go to Custom and Type 0;-0;;@

    2. Using conditional formatting.
    # On the Format menu, click Conditional Formatting.
    # In the box on the left, click Cell Value Is.
    # In the second box from the left, click equal to.
    # In the box on the right, type 0.
    # Click Format, and then click the Font tab.
    # In the Color box, select white.

    3. Modifying your formula above:
    =IF(INDEX($B$2:$B$251,MATCH(TRUE,INDEX(ISNUMBER(SEARCH($A$2:$A$251,H2)),0),0))=0,"",INDEX($B$2:$B$251,MATCH(TRUE,INDEX(ISNUMBER(SEARCH($A$2:$A$251,H2)),0),0)))
    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

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: If a Value Doesn't Exist in a Table, Return ""

    Wrap your function in an IF(ISERROR()) statement
    e.g.
    =IF(ISERROR("Your Formula"),"","Your Formula")

    Or, if you only need to work with 2007 or later
    =IFERROR("Your Formula,"")
    Last edited by Marcol; 06-17-2011 at 04:54 PM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  5. #5
    Forum Contributor
    Join Date
    05-29-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    2021
    Posts
    205

    Re: If a Value Doesn't Exist in a Table, Return ""

    Thanks guys for looking into this.

    TM, I ETA an attached example

    Ron, I can't use your first 2 methods because i'm looking for something automated for future uses.

    Ron and Marcol,

    I tried your formulas, but I couldn't get them to work

  6. #6
    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: If a Value Doesn't Exist in a Table, Return ""

    Quote Originally Posted by Ocean Zhang View Post
    Ron, I can't use your first 2 methods because i'm looking for something automated for future uses.
    I don't see why this should be a problem. If you use a custom number format or conditional formatting on the formula it will be saved along with the workbook, and if you copy (or drag) your formula the formatting will go with it (unless you specify otherwise) as well)

    Quote Originally Posted by Ocean Zhang View Post
    Ron and Marcol,

    I tried your formulas, but I couldn't get them to work
    If your original formula works, then the error management or the zero-provision should work. If you notice I didn't change your formula, all I did was to enclose it within an IF formula.

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: If a Value Doesn't Exist in a Table, Return ""

    Is this array formula what you mean?

    In C1
    Please Login or Register  to view this content.
    Confirm with Ctrl+Shift+Enter not just Enter
    Then Drag/Fill Down

  8. #8
    Forum Contributor
    Join Date
    05-29-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    2021
    Posts
    205

    Re: If a Value Doesn't Exist in a Table, Return ""

    It worked. Thanks!

+ 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