+ Reply to Thread
Results 1 to 6 of 6

IF Statement Logical Test Prob finding "#n/a"

  1. #1
    Registered User
    Join Date
    06-18-2010
    Location
    Dallas
    MS-Off Ver
    Excel 2007
    Posts
    59

    Post IF Statement Logical Test Prob finding "#n/a"

    Hello,

    I am having some slight difficulty getting this simple if statement to work and I am pretty sure it has to do with the logical test in the formula.

    In the example I have attached, I write =IF(E2="#N/A",C2,0)
    which I intend to mean:
    if cell E2 = "#N/A", give me the contents of C2, if not, output the value 0

    This does work however if i change the referenced column and the code to equal just "N/A"

    I was just wondering if there was a way of doing this in one step.

    Thanks,

    -vargs
    Attached Files Attached Files
    Last edited by vargs; 05-23-2011 at 04:20 PM.

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

    Re: IF Statement Logical Test Prob finding "#n/a"

    #N/A is actually an error message and is not seen as text. There's a function ISNA(Cell) specific for this so

    =IF(ISNA(E2),C2,0)
    Does that work for you?
    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

  3. #3
    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,507

    Re: IF Statement Logical Test Prob finding "#n/a"

    Try:

    =IF(ISNA(E2),C2,0)


    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


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

    Re: IF Statement Logical Test Prob finding "#n/a"

    Try using the IsError function instead:

    Please Login or Register  to view this content.
    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

  5. #5
    Registered User
    Join Date
    06-18-2010
    Location
    Dallas
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: IF Statement Logical Test Prob finding "#n/a"

    Both of those statements worked great.

    That is neat how you,TM Shucks and davegugg, each had a different approach that are equally as good.

    Thanks so much for your help.

    Sincerely,

    -vargs

  6. #6
    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,507

    Re: IF Statement Logical Test Prob finding "#n/a"

    You're welcome. It's quite fascinating how many ways you can find to solve a problem ;-)

    Thanks for the rep.

    Regards

+ 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