+ Reply to Thread
Results 1 to 11 of 11

10 digit numbers in cell To be replaced

  1. #1
    Registered User
    Join Date
    08-15-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    8

    10 digit numbers in cell To be replaced

    Dear Masters,
    Greetings,

    Query is as follows I have number like this in cell 8700512345.it will be always 10 digits.
    I want to replace 5 number by new number 6 for example 8700612345 .
    Problem is that it should be replaced only if it's true that 5number is 5 and if it's other number no substitute to be done.
    I am able to this by breaking the number right and left and then in midddle 0 and the joining all.
    I have used substitute formula but it fails when 5 number is other than 5.
    Thanks and regards
    Amit

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: 10 digit numbers in cell To be replaced

    With number in A1

    In cell you want result

    Please Login or Register  to view this content.
    Kind regards
    Leo

  3. #3
    Registered User
    Join Date
    08-15-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    8

    Re: 10 digit numbers in cell To be replaced

    Thanks
    I tried it but it went into error

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,938

    Re: 10 digit numbers in cell To be replaced

    Have you tried changing semi-colons to commas?

    =IF(MID(A1,5,1)="5",LEFT(A1,4)&6&RIGHT(A1,5),A1)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2503 Build 16.0.18604.20000) 64-bit
    Posts
    3,998

    Re: 10 digit numbers in cell To be replaced

    Assuming your data iin A1

    B1=IF(MID(A1,5,1)="5",REPLACE(A1,4,1,6),A1)

    P.s-Replace function does not change numbers into text.
    Hope it will help you.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  6. #6
    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
    53,048

    Re: 10 digit numbers in cell To be replaced

    Another version...
    =A1+if(mid(A1,5,1)=5,100000,0)
    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

  7. #7
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2503 Build 16.0.18604.20000) 64-bit
    Posts
    3,998

    Re: 10 digit numbers in cell To be replaced

    Quote Originally Posted by FDibbins View Post
    Another version...
    =A1+if(mid(A1,5,1)=5,100000,0)
    Mr. Ford

    =A1+if(mid(A1,5,1)="5",100000,0)

    Double quotes was missing in logical test but This is beautiful trick

  8. #8
    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
    53,048

    Re: 10 digit numbers in cell To be replaced

    oops yes, thanks, I did leave out the ""

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: 10 digit numbers in cell To be replaced

    Since the requirement is also;
    Problem is that it should be replaced only if it's true that 5number is 5 and if it's other number no substitute to be done.
    I would suggest that the formula to be amended to :
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    to cater for the display of "Blanks" if 5<>5

    or
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    to avoid the display of "Blanks" if 5<>5 or "0" if Range Row A is Empty.

    Cheers guys!
    Last edited by Winon; 08-16-2016 at 02:14 PM. Reason: Improved explaination
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  10. #10
    Registered User
    Join Date
    08-15-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    8

    Re: 10 digit numbers in cell To be replaced

    Thanks for the feedback

  11. #11
    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
    53,048

    Re: 10 digit numbers in cell To be replaced

    Thanks for the feedback

+ 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. Macro to identify 3-digit and 4-digit numbers as valid dates
    By gojakie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2015, 08:16 AM
  2. [SOLVED] LOTTERY FILTER#4, Find if 1 Digit Sum of 2 Digit or 3 Digit, Single Cell w/ dash
    By david gonzalez in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-08-2014, 12:57 AM
  3. Extract 4 digit common numbers from 5 digit numbers
    By ameque in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-24-2013, 01:09 AM
  4. Replace all one-digit number with two-digit numbers
    By sandykunaish in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2013, 09:56 AM
  5. [SOLVED] macro to extract 9 digit numbers as well as alpha numberic 9 digit numbers from txt file
    By Raju Radhakrishnan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2012, 10:15 AM
  6. To count numbers with 4 digit/5 digit with given Range.
    By ebin charles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2012, 08:49 AM
  7. Numbers Converted to Text - Last Digit Replaced by Zero
    By Cheryl B. in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-27-2005, 05:05 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