+ Reply to Thread
Results 1 to 5 of 5

Remove duplicates from a string only from right

  1. #1
    Registered User
    Join Date
    01-26-2020
    Location
    Warsaw, Poland
    MS-Off Ver
    365
    Posts
    28

    Remove duplicates from a string only from right

    Hi, I have a problem and surprisingly I cannot find easy answer to this. Is there a way to use formula (even complexed one) to remove repeating signs or letters ONLY from the end of a string in excel? For example to remove all "\" from the end of strings below (each would be in a separate row), but leaving "\" in the rest of the string:

    \\emea.com\folder_01\subfolder\many_files\\\
    \\emea.com\folder_02\subfolder2\something\\\\\
    \\emea.com\folder_03\sub\\

    There will be hundreds of rows so I need one formula to drag down...

    Thanks!

  2. #2
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Remove duplicates from a string only from right

    Given your example strings above, do you want the final results to be

    \\emea.com\folder_01\subfolder\many_files
    \\emea.com\folder_02\subfolder2\something
    \\emea.com\folder_03\sub

    ? If so, easier to use a defined name like seq referring to =ROW(INDEX($1:$1048576,1,1):INDEX($1:$1048576,255,1))-1 and cell formulas like

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

    where X99 is a placeholder for the actual cells addresses containing such strings. ADDED: this is an array formula; hold down [Ctrl] and [Shift] keys before pressing [Enter].

    The definition of seq is immune to row insertion/deletion. It evaluates to an array of sequential integers from 0 to 254. If your strings could be longer than 255 characters, increase the 255 in the definition of seq.

    This is something both LibreOffice Calc and Google Sheets handle much better than Excel. Those others provide regular expression functions. In Google Sheets, this only takes

    =REGEXREPLACE(X99,"\\*$","")
    Last edited by hrlngrv; 02-13-2021 at 06:33 PM. Reason: addendum

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,442

    Re: Remove duplicates from a string only from right

    This array-entered** formula should also work...
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    **Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself

  4. #4
    Registered User
    Join Date
    01-11-2021
    Location
    CANADA
    MS-Off Ver
    Excel 2007, Office 2019
    Posts
    35

    Re: Remove duplicates from a string only from right

    If your text always begin with double backslash then you can use this formula

    =LEFT(A1,LEN(TRIM(SUBSTITUTE(A1,"\"," ")))+2)

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,442

    Re: Remove duplicates from a string only from right

    Quote Originally Posted by Adtxc View Post
    If your text always begin with double backslash then you can use this formula

    =LEFT(A1,LEN(TRIM(SUBSTITUTE(A1,"\"," ")))+2)
    What about if a directory name begins or ends with a space or has two or more consecutive spaces in its name? Not likely but definitely possible.

+ 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. Replies: 6
    Last Post: 11-27-2018, 07:17 AM
  2. [SOLVED] Remove duplicates in Excel 2016 text string in one cell
    By martin7b in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-31-2017, 02:07 AM
  3. VBA: remove duplicates from cell or string
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-22-2017, 07:58 AM
  4. [SOLVED] Concatinate string of text and remove duplicates
    By msmayhugh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-20-2015, 06:38 PM
  5. remove duplicates from csv string
    By nikko50 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2014, 01:24 PM
  6. Replies: 5
    Last Post: 02-28-2012, 02:52 PM
  7. Replies: 2
    Last Post: 03-20-2011, 11:19 AM

Tags for this Thread

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