+ Reply to Thread
Results 1 to 5 of 5

IF function not working..

  1. #1
    Registered User
    Join Date
    08-22-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    51

    IF function not working..

    Hi

    I am trying to apply an IF function formula however am being prompted with an error

    In cell A1:A5 i have sets of numbers:

    A1: 564
    A2:4542
    A3: 68948
    A4: 987456
    A5: 8759048

    I am trying to apply the following IF function to add 0's so they are 8 digits long and then add the letter x at the end e.g.

    Please Login or Register  to view this content.
    What i would like to happen:

    B1:00000564x
    B2:00004542x
    B3:00068948x
    B4:00987456x
    B5:08759048x
    if B6 has 8 digits, i want it to be left as it is

    Please advise, much appreciated.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: IF function not working..

    Try it this way:

    =REPT("0",8-LEN(A1))&A1&"x"

    or like this:

    =RIGHT("0000000"&A1&"x",9)

    Hope this helps.

    Pete
    Last edited by Pete_UK; 12-10-2012 at 12:19 PM.

  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 function not working..

    =text(a1,"00000000")&"x" or if you dont want x added if its already 8 digits
    =text(a1,"00000000")&if(len(a1)=8,"","x")
    Last edited by martindwilson; 12-10-2012 at 12:14 PM.
    "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
    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,938

    Re: IF function not working..

    remove all the ) after A1...
    =IF(LEN(A1)=3,"00000"&A1&"x",IF(LEN(A1)=4,"0000"&A1&"x",IF(LEN(A1)=5,"000"&A1&"x",IF(LEN(A1)=6,"00"&A1&"x",IF(LEN(A1)=7,"0"&A1&"x")))))

    or a much shorter...
    =REPT("0",8-LEN(A1))&A1&"x"
    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
    08-22-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: IF function not working..

    Hi FDibbins

    =REPT("0",8-LEN(A1))&A1&"x"

    ^^ worked for me great stuff.

    Cheers

    Thanks to all others for your input

+ 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