+ Reply to Thread
Results 1 to 8 of 8

IF formula help; if ?=general letter, what = general number

  1. #1
    Registered User
    Join Date
    10-24-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    27

    IF formula help; if ?=general letter, what = general number

    Hi,

    Looking for a bit of help with an IF formula. I want to check that a cell contains a specific sequence to ensure the data has been entered correctly, but I'm coming up with errors as I don't know how to just tell excel it needs to look for any number.

    e.g. =IF(A1="NR########","PASS","FAIL")

    # could be any number, it just has to start with NR and has to have a string of 8 numbers from NR00000001 - NR99999999. The problem I've encountered is that if you just say >NR00000001 and you have NR141 it passes, but it needs to have the full 8 digits after the NR.

    Any help would be great!!

    Toby
    Last edited by tcw1986; 12-18-2011 at 11:06 AM. Reason: Solved

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: IF formula help; if ?=general letter, what = general number

    Perhaps =IF(and((left(a1,2)="nr"),len(a1)=10),"PASS","FAIL")

    Could it be that the eight digits after NR are not a number ?

    EDIT in that case =IF(and((left(a1,2)="nr"),len(a1)=10,isnumber(right(a1,8)),"PASS","FAIL")
    Last edited by arthurbr; 12-16-2011 at 10:49 AM.

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

    Re: IF formula help; if ?=general letter, what = general number

    =IF(AND(LEN(A1)=10,LEFT(A1,2)="nr",ISNUMBER(RIGHT(A1,8)+0)),"pass","fail")
    "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

  4. #4
    Registered User
    Join Date
    10-24-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: IF formula help; if ?=general letter, what = general number

    That appears to work. That's great!

    The 8 digits following NR would only ever be digits and never letters.

    Thanks Again!

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: IF formula help; if ?=general letter, what = general number

    If you want to ensure that you have NR not nr or Nr then you could amend that to

    =IF(AND(LEN(A1)=10,EXACT(LEFT(A1,2),"NR"),ISNUMBER(RIGHT(A1,8)+0)),"pass","fail")
    Audere est facere

  6. #6
    Registered User
    Join Date
    10-24-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: IF formula help; if ?=general letter, what = general number

    That's great!

    Thank you all for your help!

    Toby

  7. #7
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: IF formula help; if ?=general letter, what = general number

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  8. #8
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: IF formula help; if ?=general letter, what = general number

    I think this wouldn't work in some conditions.

    Say, some one enter NR a space then 7 digit, or NR 7 space one digit

    Please Login or Register  to view this content.
    Try this one

    =IF(AND(LEN(A2)=10,EXACT(LEFT(A2,2),"NR"),COUNT(MID(A2,{3,4,5,6,7,8,9,10},1)+0)=8),"Pass","Fail")
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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