+ Reply to Thread
Results 1 to 3 of 3

Force right text formula to return 4 characters if only 3 are in referencing cell

  1. #1
    Forum Contributor
    Join Date
    10-11-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    230

    Force right text formula to return 4 characters if only 3 are in referencing cell

    I have the following formula: TEXT(RIGHT(E106,4),"0000")
    It will return the first 4 characters in cell E106. I need to adjust that formula so that if cell E106 only has 3 charcacters or two or one then it will put zeros before those characters. Example:
    If E106 = A10A56, the current formula will return A10A
    If E106 = A10, the current formula will return A10 but I need it to return 0A10
    If E106 = A1, the current formula will return A1 but I need it to return 00A1
    etc.
    Thanks.

  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: Force right text formula to return 4 characters if only 3 are in referencing cell

    err right() would give the other end of the string! dont you mean left() ?
    TRY
    =REPT("0",MAX(0,4-LEN(A1)))&LEFT(A1,4)
    Last edited by martindwilson; 09-18-2014 at 05:41 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

  3. #3
    Forum Contributor
    Join Date
    10-11-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    230

    Re: Force right text formula to return 4 characters if only 3 are in referencing cell

    sorry, yes, I meant left. I really do know my left from my right. Thanks for catching that.

+ 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] How can I force characters and spaces in a cell over 80 to a new cell? Excel 2007
    By SylviaM in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-17-2014, 01:22 PM
  2. Replies: 3
    Last Post: 12-17-2012, 07:28 AM
  3. [SOLVED] Referencing cell value or text within a formula
    By BPSJACK in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-28-2012, 12:14 PM
  4. [SOLVED] Help to return only first 12 characters when a cell contains specific text
    By ports83 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-25-2012, 10:30 PM
  5. Referencing text in a cell in a formula
    By jimbob in forum Excel General
    Replies: 3
    Last Post: 02-27-2006, 07:15 PM

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