+ Reply to Thread
Results 1 to 7 of 7

Need text in column fixed

  1. #1
    Registered User
    Join Date
    12-11-2006
    Posts
    2

    Need text in column fixed

    I am a novice but have been lurking here a while. Can't find help for this one, should be simple for you guys. Have a column of one word text that looks like this, PHIL3C, SCHM2P, KOLL1C and so on. Evey once in a while I have an error such as PHILC3, the last letter and number reversed. I need a function to examine the cell and correct to PHIL3C. Help please.

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    As long as all the valid names are stored somwhere, you can have a Data Validation List which will prevent all mistakes ...

    HTH
    Carim

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    If your text changes this should work as it

    1). Checks first 4 letters are text
    2). Checks that the string length is 6 characters
    3). Checks that the 5th character is a number
    4). Checks that the last character isn't a number

    =AND(ISTEXT(LEFT(A1,4)),COUNTIF(A1,"??????")=1,RIGHT(A1,1)<>{"1",",2","3","4","5","6","7","8","9","0"},OR(MID(A1,5,1)={"1",",2","3","4","5","6","7","8","9","0"}))

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Valued Forum Contributor
    Join Date
    03-25-2004
    Location
    Boston, MA US
    Posts
    1,094
    If you are only concerned with the last two characters in the string you could try,

    =IF(ISNUMBER(VALUE(RIGHT(A1,1))),LEFT(A1,LEN(A1)-2)&RIGHT(A1,1)&MID(A1,LEN(A1)-1,1),A1)



    HTH

    Steve

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

    =IF(ISERR(RIGHT(A1)+0),A1,REPLACE(LEFT(A1,5),5,0,RIGHT(A1)))

  6. #6
    Registered User
    Join Date
    12-11-2006
    Posts
    2
    Thanks guy's all is well!

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Glad you got your answer

    VBA Noob

+ 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