+ Reply to Thread
Results 1 to 10 of 10

Advanced Find and Replace by Column

  1. #1
    Registered User
    Join Date
    07-28-2015
    Location
    chicago, illinois
    MS-Off Ver
    2013
    Posts
    28

    Advanced Find and Replace by Column

    I have attached an example spreadsheet.

    Here is what I am trying to do. I have a column with 5 digit extensions and a column for 11 digit extensions. These extensions are in two different ranges. 5XXXX and 7XXXX. I need a formula that will check the values in the column and if it finds a number that begins with 5XXXX then transform it into 1312555XXXX or if it finds a 7XXXX transform it into 1312777XXXX.

    I am sure this is easy to accomplish.

    Thanks!
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Advanced Find and Replace by Column

    See attached.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,216

    Re: Advanced Find and Replace by Column

    try

    =IF(LEFT(B2,1)="5","131255"&B2,IF(LEFT(B2,1)="7","131277" &B2,""))

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Advanced Find and Replace by Column

    Using your posted workbook

    try this formula, copied down:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Advanced Find and Replace by Column

    One more

    =INDEX({"131255","131277"}&B2,IF(LEFT(B2)="5",1,IF(LEFT(B2)="7",2,"")))
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Registered User
    Join Date
    07-28-2015
    Location
    chicago, illinois
    MS-Off Ver
    2013
    Posts
    28

    Re: Advanced Find and Replace by Column

    I just got back to my work station, I will try each and let you know which is most efficient and scalable, should I need to include additional ranges.

    Will report back soon! Thanks!

  7. #7
    Registered User
    Join Date
    07-28-2015
    Location
    chicago, illinois
    MS-Off Ver
    2013
    Posts
    28

    Re: Advanced Find and Replace by Column

    Ron Coderre is the winner!

    I find this formula easiest on the eyes and easiest to scale, though I am quite impressed with the different ways to arrive at a solution. There were a couple of different angles I did not consider.

    =CHOOSE(MATCH(LEFT(B2,1),{"A","B"},0),"X","Y")&B2 is a great template to work from. Is there an upper limit to the search criteria within the squiggly brackets?

    Ron, this is the first time I am using the CHOOSE function. Neat stuff.

    Rep give, appreaction for all.

    Thank you again, I'm sure I'll have another post soon.

  8. #8
    Registered User
    Join Date
    07-28-2015
    Location
    chicago, illinois
    MS-Off Ver
    2013
    Posts
    28

    Re: Advanced Find and Replace by Column

    One last question

    Is is possible to wrap this in an IFERROR to display a black cell instead of #N/A in the case that the source cell is blank

    I have been tinkering around with this... but no luck.

    =IFERROR(CHOOSE(MATCH(LEFT(B2,1),{"A","B"},0),"X","Y")&B2 "")

    Any advice?


    EDIT: This seems to work, is it an elegant solution though? Is that in the eye of the beholder? =CHOOSE(MATCH(LEFT(B2,1),{"","A","B"},0),"","X","Y")&B2
    Thanks!
    Last edited by xDimitrius; 09-22-2015 at 12:11 PM.

  9. #9
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Advanced Find and Replace by Column

    I think this variation catches all errors...
    Please Login or Register  to view this content.
    but I don't know if you gain anything by matching a blank string, so this might work just as efficiently:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-28-2015
    Location
    chicago, illinois
    MS-Off Ver
    2013
    Posts
    28

    Re: Advanced Find and Replace by Column

    =IFERROR(CHOOSE(MATCH(LEFT(B2,1),{"","A","B"},0),"","X","Y")&B2,"")

    I've settled on this forumula.

    Topic marked Solved.

    Thanks again for all of the contributors to this thread.

    Regards

+ 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. Advanced replace and find formula help
    By jschleider in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-18-2014, 11:32 PM
  2. Replies: 3
    Last Post: 11-25-2014, 06:08 AM
  3. Advanced Find and Replace VBA Help
    By Remotruker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-06-2012, 05:27 PM
  4. Advanced Find and Replace
    By lucydear in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2010, 08:58 AM
  5. Excel 2007 : advanced find and replace/apend
    By sip in forum Excel General
    Replies: 9
    Last Post: 07-16-2008, 09:00 PM
  6. Advanced Find and Replace Question
    By Ryan in forum Excel General
    Replies: 3
    Last Post: 08-06-2006, 02:00 PM
  7. [SOLVED] Advanced Find and Replace Question
    By Ryan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-05-2006, 11:00 AM

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