+ Reply to Thread
Results 1 to 14 of 14

Remove certain characters from the end of a string only

  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Remove certain characters from the end of a string only

    Hi,

    im looking to remove symbols from the end of a string only, even if the symbol occurs in the middle of the string. i have a column full of different numbers, some cells including letters and symbols as well, and need any cell that ends with a symbol, such as a full-stop, to have the symbol deleted to just leave the number.

    for example:

    0054671..ljahd156. => 0054671..ljahd156
    hdfiod465..... => hdfiod465
    ha56756..g465 => ha56756..g465
    48131532.... => 48131532

    I have tried a few different "LEFT" formulas but it seems as though it needs the same amount of characters at the end of each cell to work properly and the cell content i have is not consistent like that.

    Any ideas?

    Thanks,

    Tom

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Remove certain characters from the end of a string only

    Please make your sample data in an excel file and attach it since unable to identify which one is the separator whether dot or =>.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    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
    52,933

    Re: Remove certain characters from the end of a string only

    if you do in fact have .. in the middle of the text string, use this...
    =IF(RIGHT(A1,1)=".",LEFT(A1,LEN(A1)-1),A1)

    if the .. was just something you put into the data here (to show missing info?), then use =SUBSTITUTE(A1,".","")
    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

  4. #4
    Registered User
    Join Date
    12-17-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Remove certain characters from the end of a string only

    Apologies, see the below attachment for the data

    Remove symbols from end of cell only example.xlsx

    Cheers

  5. #5
    Registered User
    Join Date
    12-17-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Remove certain characters from the end of a string only

    the first forumla only removes 1 full-stop from the end of the string in the cell, whereas there are some cells with multiple full-stops at the end that need to be removed. but the full-stops in the middle of the strings of text need to remain so the substitute forumla is no good.

  6. #6
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Remove certain characters from the end of a string only

    If you don't mind a UDF solution, check the attachment

    Hope this helps
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  7. #7
    Registered User
    Join Date
    12-17-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Remove certain characters from the end of a string only

    the UDF solution you have provided in the attachment works perfectly. However, how do i implement the same formula you have used into a different workbook? when i try it comes up with #NAME? in the cell.

    I have no experience when it comes to UDF but am keen to use the solution you provided unless there is an easier way.

    cheers

  8. #8
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Remove certain characters from the end of a string only

    oops,my bad..
    copy this
    Please Login or Register  to view this content.
    then in the new workbook, open the VBA editor (<alt> +<F11>)
    Insert ->Module - paste
    save, close the editor and use

    Edit-
    when you save, it will probably tell you the workbook is not macro enabled, so you will have to Save As, Excel Macro-Enabled Workbook
    Last edited by dredwolf; 12-18-2012 at 01:52 AM.

  9. #9
    Registered User
    Join Date
    12-17-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Remove certain characters from the end of a string only

    you're a genius!

    works out well.

    thanks heaps, much appreciated

    Tom

  10. #10
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Remove certain characters from the end of a string only

    You are very welcome

  11. #11
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Remove certain characters from the end of a string only

    Or in B2 - Array Formula - Requires Ctrl+Shift+Enter

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


    Drag it down

  12. #12
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Remove certain characters from the end of a string only

    array formula
    {=SUBSTITUTE(LEFT(A2;MAX(IF(MID(A2;ROW(INDIRECT(1&":"&LEN(A2)));1)<>".";ROW(INDIRECT(1&":"&LEN(A2))))));CHAR(133);"")}

  13. #13
    Registered User
    Join Date
    12-17-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Remove certain characters from the end of a string only

    Sixthsense the formula you provided does not work, as it comes up with a blank cell.

    Ghozi your formula works well. out of curiosity, how would i go about adding to the parameters to remove any symbol from the end of the string, for example if the string is "456abc../#" and i wanted it to be "456abc" what would i add to your formula to remove the "/" and "#" as well as the "."??

  14. #14
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Remove certain characters from the end of a string only

    see if the attached helps...

    create a Defined Name (ALT > M > N) called "midtxt" (without the quotes). this assumes your data are in column A and no value is longer than 25 characters (you can change this if you need to).

    Please Login or Register  to view this content.
    then, place this formula in cell B1 (or wherever else your input data start, and update cell references accordingly), ARRAY-confirm and drag-fill down:

    Please Login or Register  to view this content.
    UPDATE:

    slightly shorter version of the formula in B1:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by icestationzbra; 12-20-2012 at 03:57 PM.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

+ 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