+ Reply to Thread
Results 1 to 15 of 15

Replacing text

  1. #1
    Registered User
    Join Date
    07-26-2011
    Location
    New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    43

    Replacing text

    I have thousands of reference codes just like below and I need a formula that changes the code from this:

    ENW000000159794
    ENW000000159834
    ENW000000159862
    ENW0000135968-E
    ENW0000135968-G
    ENW0000139386-E

    To this:

    159794
    159834
    159862
    135968
    135968
    139386

    Basically removing all the ENW's and 0's in front as well as any "-E" or "-"G"'s on the end.

    Can anyone help?

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Replacing text

    hello

    are you using 2010?

    try using the DATA - TEXT to COLUMN
    use first the 0 as delimeter then 2nd time use the -

    hope helps.
    by the way it will create a different column 2 or 3 columns ..

  3. #3
    Registered User
    Join Date
    07-26-2011
    Location
    New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Replacing text

    Quote Originally Posted by vlady View Post
    hello

    are you using 2010?

    try using the DATA - TEXT to COLUMN
    use first the 0 as delimeter then 2nd time use the -

    hope helps.
    by the way it will create a different column 2 or 3 columns ..
    I'm using 2007, but thanks, i'm willing to give anything a try right now.

  4. #4
    Registered User
    Join Date
    07-26-2011
    Location
    New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Replacing text

    I have got it to remove the ENW by using the formula "=RIGHT(A2,LEN(A2)-3)" so I need another formula that will just remove a -G or -E from the left hand side. Then hopefully excel will recognise it as a number and automatically format out all the 0's.

  5. #5
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Replacing text

    you'll have some problems if you use that formula, cutting off the characters will not solve that.
    attached is a sample picture for you.
    Attached Images Attached Images

  6. #6
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: Replacing text

    The characters still to be removed, will there always be -G or -E? Can there be any other? If not then its fairly simple to remove them and by adding a +0 to the end it will convert it to numeric and should indeed lose the leading 0's

    The formula will be almost identical to the one you've used at the start, replace Right function with Left and replace the -3 with -2 and at the extreme end of the formula do a + o to convert to numeric
    Last edited by scottylad2; 09-29-2011 at 01:47 AM.
    Windows 7 using Office 2007 & 2010

    Remember your [ code ] [ /code ] tags, makes reading soooo much easier

  7. #7
    Registered User
    Join Date
    09-29-2011
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Replacing text

    =RIGHT(A1,LEN(A1)-FIND("1",A1)+1)

    Try this.. Still figuring out how the 'E-'s & 'G-'s are to be removed

  8. #8
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Replacing text

    Still in eradicating "es & Gs" ??

    try this
    C1 = contains numbers with -E & - G

    =LEFT(C1,LEN(C1)-FIND("-",C1)+4)

  9. #9
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: Replacing text

    Single cell solution

    =IF(ISNUMBER(SEARCH("-",RIGHT(A1,LEN(A1)-3))),LEFT(RIGHT(A1,LEN(A1)-3),LEN(RIGHT(A1,LEN(A1)-3))-2),RIGHT(A1,LEN(A1)-3))+0

  10. #10
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Replacing text

    Another singel cell solution

    =IF(MID(A1,LEN(A1)-1,1)="-",MID(A1,4,LEN(A1)-5)*1,MID(A1,4,LEN(A1)-3)*1)

    Alf

  11. #11
    Registered User
    Join Date
    07-26-2011
    Location
    New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Replacing text

    Incredible!

    I managed to figure it out with a 6 column solution but the single column solution is great!

    Cheers

  12. #12
    Registered User
    Join Date
    07-26-2011
    Location
    New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Replacing text

    Ok how do I mark this thread as solved?

  13. #13
    Registered User
    Join Date
    09-29-2011
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Replacing text

    Quote Originally Posted by Alf View Post
    Another singel cell solution

    =IF(MID(A1,LEN(A1)-1,1)="-",MID(A1,4,LEN(A1)-5)*1,MID(A1,4,LEN(A1)-3)*1)

    Alf
    Dear Alf,

    Please could you explain your formula?

    Thanks

  14. #14
    Registered User
    Join Date
    09-29-2011
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Replacing text

    Quote Originally Posted by johnrichie View Post
    Dear Alf,

    Please could you explain your formula?

    Thanks
    Thanks Alf.. figured it out

  15. #15
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Replacing text

    Hi percyth1

    Ok how do I mark this thread as solved?
    Like this

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.
    and a word of warning never use your mail adress in an open forum unless you wish to recive loads of spam in your mail box.

    Hi johnrichie

    I guess it was the *1 that you did'n figure out at once. Was a bit unsure myself as the OP never said if the result should be a string or a number. So I took a chance thinking a number would be ok.

    Alf

+ 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