+ Reply to Thread
Results 1 to 12 of 12

replace

  1. #1
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    replace

    Hello everyone.
    I have a series of cells (more than 800) placed with this text:

    00123456789-FFF
    00123456788-FFF
    00123456787
    00123456777-FFF
    00123456999-FFF
    00123455555-FFF
    00123456444

    I have to remove all the final -FFF
    I tried but then replace the text becomes

    123456789
    123456788
    00123456787
    123456777
    123456999
    123455555
    00123456444

    the text should remain the initial 00 well:

    00123456789
    00123456788
    00123456787
    00123456777
    00123456999
    00123455555
    00123456444

    a help?
    Thank you in advance.
    max max

  2. #2
    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: replace

    Try this formula in B1 and copy down

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


    Excel 2016
    A
    B
    1
    00123456789-FFF 00123456789
    2
    00123456788-FFF 00123456788
    3
    00123456787 00123456787
    4
    00123456777-FFF 00123456777
    5
    00123456999-FFF 00123456999
    6
    00123455555-FFF 00123455555
    7
    00123456444 00123456444
    Sheet: Sheet3
    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

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

    Re: replace

    Using your sample data...try this:

    • Select the single-column range of cells to be impacted
    • Data.Text-to-columns
    ...Click: Fixed width........Click: Next
    ...Insert a break point just before the dash...Click: Next
    ...Set the first column to TEXT
    ...Set the 2nd column to "Do not import column (skip)"
    ...Click: Finish

    The end result will be:
    A
    1
    00123456789
    2
    00123456788
    3
    00123456787
    4
    00123456777
    5
    00123456999
    6
    00123455555
    7
    00123456444

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,037

    Re: replace

    try this on the cells having text =REPLACE(A1,LEN(A1)-4,5,"")

    EDIT: I like Ron and Alkey's solution better than mine.
    Last edited by alansidman; 12-21-2015 at 04:07 PM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

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

    Re: replace

    Since you indicated VBA....
    When using VBA to implement Text-to-columns,
    you have the option to indicate the data type of each field being parsed.

    Sample data in A1:A7
    Please Login or Register  to view this content.
    Where:
    Field 1 is text
    Field 2 is anything, actually

    Please Login or Register  to view this content.
    The FieldInfo parameter, which is implemented this way, determines the data type:
    FieldInfo:=Array(Array(0, 2), Array(11, 9))

    For fixed-width source data,
    the first argument of each array identifies a field by position (beginning with location 0)
    and
    the second argument of each array indicates the data type
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: replace

    Hello all good solutions.
    Unfortunately, we must eliminate the final -FFF only cells with -FFF.
    In the column there are various different cells as text type:

    9314-04321-77
    7314-04736-88
    1014-04920-99
    00123456789-FFF
    00123456788-FFF
    00123456787
    00123456777-FFF
    1017777
    1017888
    1017777
    00123456999-FFF
    00123455555-FFF
    00123456444
    1514-05156-11
    1614-05158-44

    with the solutions change all the numbers.
    For examples must be posted:

    9314-04321-77
    7314-04736-88
    1014-04920-99
    00123456789
    00123456788
    00123456787
    00123456777
    1017777
    1017888
    1017777
    00123456999
    00123455555
    00123456444
    1514-05156-11
    1614-05158-44

    max_max

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

    Re: replace

    OK...then, maybe this:

    • Select the range of cells to be impacted
    • Home...Number section...Select: Text
    • Home.Find&Replace.Replace
    ...Find what: -FFF
    ...Replace with: (leave this blank)
    ...Click: Replace All

    By converting the range to text first, the values won't convert to numbers after the "-FFF" is removed.

    Does that help?

  8. #8
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: replace

    I tried as directed by Ron Coderre but does not leave the 00 initial numbers with -FFF final.
    I attach an example.
    max_max

    replace.xls

  9. #9
    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: replace

    Here is with another formula

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


    Data Range
    A
    B
    3
    9314-04321-77
    9314-04321-77
    4
    7314-04736-88
    7314-04736-88
    5
    1014-04920-99
    1014-04920-99
    6
    00123456789-FFF
    00123456789
    7
    00123456788-FFF
    00123456788
    8
    123456787
    123456787
    9
    00123456777-FFF
    00123456777
    10
    1017777
    1017777
    11
    1017888
    1017888
    12
    1017777
    1017777
    13
    00123456999-FFF
    00123456999
    14
    00123455555-FFF
    00123455555
    15
    123456444
    123456444
    16
    1514-05156-11
    1514-05156-11
    17
    1614-05158-44
    1614-05158-44
    18
    00123456789-FFF
    00123456789
    19
    00123456788-FFF
    00123456788
    20
    123456787
    123456787
    21
    00123433777-FFF
    00123433777
    22
    1017755
    1017755
    23
    1017800
    1017800
    24
    1017777
    1017777
    25
    00127756999-FFF
    00127756999
    26
    00124445555-FFF
    00124445555
    27
    00123456999-FFF
    00123456999
    28
    00123455555-FFF
    00123455555
    29
    123456444
    123456444
    30
    1514-05156-11
    1514-05156-11
    31
    1614-05158-44
    1614-05158-44
    32
    00123456789-FFF
    00123456789
    33
    00123456788-FFF
    00123456788

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

    Re: replace

    Yes...Sorry...
    Just formatting the range as Text doesn't quite complete the process.

    Try this, instead

    • Select the single-column range of cells to be impacted
    • Home.Find&Replace.Replace
    ...Find what: -FFF
    ...Replace with: |FFF
    ...Click: Replace All

    • Data.Text-to-columns
    ...Click: Delimited........Click: Next
    ...Other: | <-that's a pipe character (above the ENTER key)........Click: Next
    ...Set the first column to TEXT
    ...Set the 2nd column to "Do not import column (skip)"
    ...Click: Finish

    Does that do what you want?

  11. #11
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: replace

    Thanks Alkey,
    the formula is perfect.
    The formula is in Italian:
    =SE(VAL.NUMERO(--DESTRA(A3));A3;SOSTITUISCI(A3;"-FFF";""))

    Thanks Ron Coderre,
    your last solution is perfect.

    Thank you all.
    Greetings from Italy.
    max_max

  12. #12
    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: replace

    Thank you for the feedback!
    Last edited by AlKey; 12-21-2015 at 06:14 PM.

+ 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. REPLACE function help replace two separate texts Ctrl H
    By Uldis in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-23-2015, 10:51 AM
  2. [SOLVED] find and replace to not replace characters found as wildcards
    By sabutler4 in forum Excel General
    Replies: 4
    Last Post: 07-03-2013, 06:48 PM
  3. Multiple Find and Replace to replace a list of strings
    By WalterP34 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-11-2011, 07:41 PM
  4. Find, and replace but copy cells before replace
    By raehippychick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2007, 08:16 AM
  5. find and replace - replace data in rows to separated by commas
    By msdker in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-14-2006, 08:10 PM
  6. How can I use replace(alt+H) for mutiple items needing replace
    By Gery in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  7. How can I use replace(alt+H) for mutiple items needing replace
    By Gery in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 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