+ Reply to Thread
Results 1 to 9 of 9

If function is interpreting a "-" as a value greater than a number. Why?

  1. #1
    Registered User
    Join Date
    12-19-2012
    Location
    Shanghai
    MS-Off Ver
    Excel 2010
    Posts
    23

    If function is interpreting a "-" as a value greater than a number. Why?

    I have a simple If formula that looks like

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    My value in C5 is a dash, not a number. But the result of the If formula is positive as if the dash was a value greater than 5000, resulting in it displaying the contents of B1.

    I'm using an IFERROR function in C5 to return a "-" if it is an error. Is there something else I can use besides a number? For example, I can't say IFERROR return a 0 as that would mess with the rest of my sheet. I'd like it to return something with no value like a simple blank space or a dash. A simple blank space also has the same result as the dash though.

    Sample attached.
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: If function is interpreting a "-" as a value greater than a number. Why?

    try changing the formula to this...
    =IF(AND(ISNUMBER(C5),C5>5000),B5,"-")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

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

    Re: If function is interpreting a "-" as a value greater than a number. Why?

    hi again. not sure if i really understood what you need and how putting a zero in the IFERROR mess up the rest. does this help?
    =IF(AND(C5>5000,C5<>"-"),B5,"-")

    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

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: If function is interpreting a "-" as a value greater than a number. Why?

    I am unable to understand your expectation Can you please describe what is your outcome?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  5. #5
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: If function is interpreting a "-" as a value greater than a number. Why?

    Maybe..

    Please Login or Register  to view this content.
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  6. #6
    Registered User
    Join Date
    12-19-2012
    Location
    Shanghai
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: If function is interpreting a "-" as a value greater than a number. Why?

    Gosh I must not have explained that very well.. apologies. The outcome I wanted in the sample I uploaded, was for column D to return what was in the corresponding cell from column B, only if the corresponding cell from Column C had a value greater than 5000.

    The problem was that, even though I didn't have a value greater than 5000 in column C, in fact I had a "-" which is not even a numeric value, the formula from column D was still interpreting it as a value greater than 5000.

    FDibbins suggestion of using the ISNUMBER function remedied the problem. Although I'm still not sure why a dash can be considered a numeric value - at least from now on I know I should use the ISNUMBER function.

    Thanks all for your help.

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: If function is interpreting a "-" as a value greater than a number. Why?

    The way you written the formula made the difference.

    The "-" is not at all considered as Numeric Value.

    Just put this formula in D5 cell and see what's happening, your formula stays as it is but just added another if to ensure whether D5 is Number.
    =IF(ISTEXT(C5),"Cell Has Text Value",IF(C5>5000,B5,"-"))

    In your formula only two conditions True or False. C5>5000 will get True or False. Here C5 is the Text Data "-" so will return False. So it should not be meant as "-" is considered as Numeric and it is >5000 value.

    Hope it's clear to you

  8. #8
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: If function is interpreting a "-" as a value greater than a number. Why?

    maybe???

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,621

    Re: If function is interpreting a "-" as a value greater than a number. Why?

    The problem was that, even though I didn't have a value greater than 5000 in column C, in fact I had a "-" which is not even a numeric value, the formula from column D was still interpreting it as a value greater than 5000.
    If you use the TYPE(cell_reference) function, you’d find that a text field returns a 2 and a number (or date) cell returns a 1. All equality comparisons are identity comparisons in Microsoft Excel, which means they compare type and value. Inequality comparisons, compare type and return a value based on the type number and never compare value when the types differ. There are three other types: (1) A logical value is 4; (2) An error message is 16; and (3) An array is 64.

+ 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