+ Reply to Thread
Results 1 to 6 of 6

IF function displays wrong information after using MID function

Hybrid View

  1. #1
    Registered User
    Join Date
    04-12-2010
    Location
    *
    MS-Off Ver
    Excel 2007
    Posts
    25

    IF function displays wrong information after using MID function

    Hi,

    Okay, so:
    A1 displays "127:15" (no quotes, text cell).
    A2 has the function MID(A1,1,3), to retrieve the number "127".
    A3 has the function IF(A2>186,"yes","no").
    A3 says: yes.
    Why?

    Thank you all!
    Last edited by blackmilk; 04-12-2010 at 11:09 AM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: IF function displays wrong information after using MID function

    try
    =IF(--A2>186,"yes","no")
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    04-12-2010
    Location
    *
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: IF function displays wrong information after using MID function

    That worked, thanks!
    What exactly do those lines do?

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: IF function displays wrong information after using MID function

    just forces it to a real number you could have also used a2+0 or a2*1 or
    =IF(VALUE(A2)>186,"yes","no")

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

    Re: IF function displays wrong information after using MID function

    To further Martin's explaination, the MID function returns text (a string). You're asking to compare that string to a number. Martin's formula will force A2 into a number. Another way would be to change your MID equation to read
    =MID(A1,1,3)+0
    Hope that helps.
    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

  6. #6
    Registered User
    Join Date
    04-12-2010
    Location
    *
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: IF function displays wrong information after using MID function

    Okay, I see.
    Thank you guys for your help and explanations

+ 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