+ Reply to Thread
Results 1 to 8 of 8

replace first 2 letters only

  1. #1
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216

    replace first 2 letters only

    mobile company changed the numbers from 012xxxxxxxxx to 0122xxxxxxxxx and from 018xxxxxxxxx to 0128xxxxxxxxx etc.
    is there a formula or VBA code to make these changes
    and i have to tell that
    1- the numbers start by 0
    2- SOME numbers start by + or 00

    which mean i want to just change the specific 2 numbers to the new 3 numbers

    i know it's possible ,but is it secure or may make a mess ?
    Last edited by nasser; 10-07-2011 at 10:56 AM.

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: replace first 2 letters only

    try to use function LEFT and REPLACE

    regards
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: replace first 2 letters only

    Without a sample of your workbook it is hard to say.
    However try this assuming your numbers are in A1 down
    Please Login or Register  to view this content.
    Drag/Fill Down
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216

    Re: replace first 2 letters only

    how to combine left and replace with IF because i have different numbers as you see , there is 012 and 018 and 016 etc...

  5. #5
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216

    Re: replace first 2 letters only

    012345667 must change to 0122345667
    018323878 must change to 0128323878
    016398989 must change to 0126398989
    015323233 must change to 0105323233
    012327773 must change to 0122327773

    +9614545454 remain the same
    00143431234 remain the same

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: replace first 2 letters only

    Try
    Please Login or Register  to view this content.
    Is this correct?
    015323233 must change to 0105323233

  7. #7
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216

    Re: replace first 2 letters only

    thank you all
    @ Marcol it works very well Thank you

  8. #8
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216

    Re: replace first 2 letters only

    as i said it works so well but i was have to change more than one code number so it will be like this

    =IF(LEFT(A1,3)="012",SUBSTITUTE(A1,"012","0122",1),IF(LEFT(A1,3)="017",SUBSTITUTE(A1,"017","0127",1),IF(LEFT(A1,3)="018",SUBSTITUTE(A1,"018","0128",1),IF(LEFT(A1,4)="0150",SUBSTITUTE(A1,"0150","0150",1),IF(LEFT(A1,3)="011",SUBSTITUTE(A1,"011","0111",1),IF(LEFT(A1,3)="014",SUBSTITUTE(A1,"014","0114",1),IF(LEFT(A1,4)="0152",SUBSTITUTE(A1,"0152","0112",1),IF(LEFT(A1,3)="010",SUBSTITUTE(A1,"010","0100",1),IF(LEFT(A1,3)="016",SUBSTITUTE(A1,"016","0106",1),IF(LEFT(A1,3)="019",SUBSTITUTE(A1,"019","0109",1),IF(LEFT(A1,4)="0151",SUBSTITUTE(A1,"0151","0101",1),A1)))))))))))

    thank you so much again

+ 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