+ Reply to Thread
Results 1 to 10 of 10

Nested If Statement - ISBLANK and ISNA in same statement?

  1. #1
    Registered User
    Join Date
    10-30-2009
    Location
    UK
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    60

    Nested If Statement - ISBLANK and ISNA in same statement?

    Hi Everyone

    I have the following formula and would like to add to it but I'm not sure where to create the additional argument:


    =IF(ISNA(VLOOKUP($A6,Sheet5!$A$3:Sheet5!$E$389,2,FALSE)),"-",VLOOKUP($A6,Sheet5!$A$3:$E$389,2,FALSE))


    Where the ISNA is false, it currently returns a zero value regardless that the cell it's copying from is blank - I would like this to show as "-" rather than a zero. I'm sure this must be possible, as I've used ISBLANK previously, I just don't know where to insert it into my formula.

    Thanks in advance for any help.

    Jan
    Last edited by Janc; 04-23-2013 at 05:19 AM. Reason: Solved

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Nested If Statement - ISBLANK and ISNA in same statement?

    hi Jan, try:
    =IF(ISERROR(1/(1/VLOOKUP($A6,Sheet5!$A$3:$E$389,2,FALSE))),"-",VLOOKUP($A6,Sheet5!$A$3:$E$389,2,FALSE))

    or actually in Excel 2007 & above:
    =IFERROR(1/(1/VLOOKUP($A6,Sheet5!$A$3:$E$389,2,FALSE)),"-")

    or use your original formula, but right-click the cells -> Format Cells -> Custom:
    General;;

    just ensure you have 2 semi-colons in each type of formats. fyi, the 1st portion is how you want to present positive numbers, 2nd for negative, 3rd for 0s, 4th for text. they are all separated by semi-colons. so i chose nothing for zeroes. the format for comma-separated values & brackets for -ve numbers for eg looks like this:
    #,##0.00_);[Red](#,##0.00)
    so to add in blank for zeroes:
    #,##0.00_);[Red](#,##0.00);

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Nested If Statement - ISBLANK and ISNA in same statement?

    What type of data does the VLOOKUP normally return? Is it text? Numeric? Could be both? Something else?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    10-30-2009
    Location
    UK
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    60

    Re: Nested If Statement - ISBLANK and ISNA in same statement?

    Quote Originally Posted by benishiryo View Post
    or actually in Excel 2007 & above:
    =IFERROR(1/(1/VLOOKUP($A6,Sheet5!$A$3:$E$389,2,FALSE)),"-")

    or use your original formula, but right-click the cells -> Format Cells -> Custom:
    General;;
    Hi and thanks for your reply.

    Formatting the cell works fine, but I would rather have something showing rather than nothing so I'm happier using the amended formula route and I have tried using the above you suggested and have a problem: It's returning "-" regardless of the actual cell value. Is this maybe because it's not encountering an error as the reference checked in the first part of the VLOOKUP is true?



    Quote Originally Posted by Tony Valko View Post
    What type of data does the VLOOKUP normally return? Is it text? Numeric? Could be both? Something else?
    For my immediate purpose, it checks to see if a name is present on Sheet5, and if it is, it will always return either a +ive numeric value (some formatted to 1 decimal place, others to no decimal places) - or the cell could be blank.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Nested If Statement - ISBLANK and ISNA in same statement?

    Quote Originally Posted by Janc View Post
    For my immediate purpose, it checks to see if a name is present on Sheet5, and if it is, it will always return either a +ive numeric value (some formatted to 1 decimal place, others to no decimal places) - or the cell could be blank.
    OK, then the 2nd suggestion from benishiryo should work:

    =IFERROR(1/(1/VLOOKUP($A6,Sheet5!$A$3:$E$389,2,0)),"-")

  6. #6
    Registered User
    Join Date
    10-30-2009
    Location
    UK
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    60

    Re: Nested If Statement - ISBLANK and ISNA in same statement?

    Thanks Tony. I've just tried this again :

    =IFERROR(1/(1/VLOOKUP($A6,Sheet5!$A$3:$E$389,2,0)),"-")

    But it's returning "-" regardless of the actual cell value. Is this maybe because it's not encountering an error as the reference checked in the first part of the VLOOKUP is true?

    I've attached sample data with comments to show the problem I'm having.
    Attached Files Attached Files

  7. #7
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Nested If Statement - ISBLANK and ISNA in same statement?

    try this in B4:
    =IFERROR(1/(1/VLOOKUP($A4,Sheet5!$A$4:$Q$8,COLUMN(),0)),"-")

    you were always referring to A4:E8 where there are only 5 columns. but in G2 onwards, you would have exceeded 5 columns. i also changed the col_index_num portion so that you don't have to keep changing from 2 to 3, to 4, etc

    and i overlooked the format cells. if you want to use with "-", you should use:
    0.0;;"-"

    that's for a single decimal

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Nested If Statement - ISBLANK and ISNA in same statement?

    If the names are in the same order on both sheets (as they are in the sample file) then you can use a simple link formula:

    This formula entered in Sheet1 B4:

    =IF(Sheet5!B4="","",Sheet5!B4)

    Copy across to Q4 then down as needed.

    If the names will be in random order:

    =IFERROR(1/(1/VLOOKUP($A4,Sheet5!$A$4:$Q$8,COLUMNS($B4:B4)+1,0)),"-")

  9. #9
    Registered User
    Join Date
    10-30-2009
    Location
    UK
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    60

    Re: Nested If Statement - ISBLANK and ISNA in same statement?

    The names can change position and not all those included on the data sheet will need to be copied across to my main working sheet so I've used the random order code from Tony and it's worked perfectly!

    I can use this formula and the formatting from benishiryo in so many different files.

    Thank you both so much for you help and patience

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Nested If Statement - ISBLANK and ISNA in same statement?

    You're welcome. Thanks for the feedback!

+ 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