+ Reply to Thread
Results 1 to 7 of 7

Logic in mid function not working

  1. #1
    Registered User
    Join Date
    12-25-2015
    Location
    Delhi, India
    MS-Off Ver
    2007
    Posts
    17

    Logic in mid function not working

    Hi There,

    Greetings for the day!

    I'm having transaction numbers in Col. A. All transaction numbers' 5th digit must be zero, however there may be zeros at other digits, 5th digits must be zero. To validate the same, i'm applying MID function in Col B as below:

    Transaction number
    TXNZ0XXX127 =MID(A2,5,1)=0

    BY applying this logic, Why I'm getting "FALSE"?
    Please help.
    Thanks
    Have a great day.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,591

    Re: Logic in mid function not working

    Because it's text. Try this:

    =VALUE(MID(A2,5,1))=0

    Welcome to the forum, by the way!
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Logic in mid function not working

    This is text you are testing for so put double quotes around zero.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    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
    52,929

    Re: Logic in mid function not working

    Just to add in to what Ali said, LEFT, MID and RIGHT all always return a text answer, even if it looks like a number. A quick give-away is that by default, text is always left-aligned and real numbers are always right aligned.

    If you extract a "number" from either a longer number or a text string, you need to convert that to a number
    either or these should work...
    =VALUE(MID(A2,5,1))=0
    or
    =--MID(A2,5,1)=0
    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

  5. #5
    Registered User
    Join Date
    12-25-2015
    Location
    Delhi, India
    MS-Off Ver
    2007
    Posts
    17

    Re: Logic in mid function not working

    Hi,

    Thanks AliGW for quick address and greatful to FDibbins for giving additional info. this helped a lot and will assist in future as well.
    GOD BLESS
    Have a great day

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,591

    Re: Logic in mid function not working

    You're welcome!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  7. #7
    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
    52,929

    Re: Logic in mid function not working

    Hanky, thank you for the belated rep, always appreciated!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] String Logic Comparison not working
    By Asepic in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-16-2015, 04:55 PM
  2. Replies: 6
    Last Post: 01-27-2014, 04:13 AM
  3. nested If logic isn't working, plz help...
    By raj3076 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-16-2013, 05:31 AM
  4. Logic function
    By i2ishailu in forum Excel General
    Replies: 5
    Last Post: 08-27-2012, 08:10 AM
  5. [SOLVED] Help with logic function
    By SheerGold in forum Excel General
    Replies: 2
    Last Post: 01-26-2012, 11:07 AM
  6. [SOLVED] Simple Copy-Paste logic not working
    By Brian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2005, 02:40 PM
  7. Logic Function Help…
    By thomasstyron in forum Excel General
    Replies: 3
    Last Post: 07-25-2005, 05:40 PM

Tags for this Thread

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