+ Reply to Thread
Results 1 to 7 of 7

Remove text between "\" regardless of number of characters

  1. #1
    Registered User
    Join Date
    11-29-2012
    Location
    ystfast
    MS-Off Ver
    Excel 2010
    Posts
    52

    Remove text between "\" regardless of number of characters

    Filename:

    U:\Pjongyang\returns\Clients\0 Client Files Sorted\P - T\Gymkata\vReturn\2012\10_12\AWP\[Gymkata_AvaTax_Upload_Data_Summary_201210_vTEST.xls]qrySelUploadSummary

    Formula:
    =CONCATENATE(LEFT(MID(CELL("filename"),FIND("\",CELL("filename"))+54,LEN(CELL("filename"))),FIND("\",MID(CELL("filename"),FIND("\",CELL("filename"))+3,LEN(CELL("filename")))))," - ","11/2012")


    Result:

    Gymkata


    I am trying to extract a company name from the file name. The company name is going to be different each time. What I wrote above works if the company name is the same length; I did not consider different counts in company names.

    U:\Pjongyang\returns\Clients\0 Client Files Sorted\P - T\Gymkata\vReturn\2012\10_12\AWP\[Gymkata_AvaTax_Upload_Data_Summary_201210_vTEST.xls]qrySelUploadSummary


    I now realize that what I really want is the text string between the 6th and 7th occurrence of "\". Can the formula I wrote be easily adapted to this change?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Remove text between "\" regardless of number of characters

    Hi,

    =MID(A1,FIND("|",SUBSTITUTE($A1,"\","|",6))+1,FIND("|",SUBSTITUTE($A1,"\","|",7))-FIND("|",SUBSTITUTE($A1,"\","|",6))-1)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-29-2012
    Location
    ystfast
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Remove text between "\" regardless of number of characters

    Nice, thank-you.

    As I read it, the formula first replacing the 6th and 7th "\" with the "|". Do you use the | to make a unique character? Then the formula extracts everything between and including the pipes, the +1,-1 peel off the pipes. Do I have that correct?

  4. #4
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Remove text between "\" regardless of number of characters

    See attached...I used helper columns and a series of formulas. You could nest them into one formula, but that can be a pain if you later need to change it.
    Attached Files Attached Files
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Remove text between "\" regardless of number of characters

    Hi,

    Exactly right!

    I should have said of course that the character you use in the substitution should not be present in the original string. So choose something unique.

  6. #6
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Remove text between "\" regardless of number of characters

    Question... if the Name of the company is always going to be immediately following the [ as noted by the red text below, with a _ immediately following the company name:
    U:\Pjongyang\returns\Clients\0 Client Files Sorted\P - T\Gymkata\vReturn\2012\10_12\AWP\[Gymkata_AvaTax_Upload_Data_Summary_201210_vTEST.xls]qrySelUploadSummary

    Then why not do something a bit simpler, like:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Heck, I'm sure some of the geniuses on here can figure out an even more efficient way than that, even.

    - Moo
    Last edited by Moo the Dog; 11-30-2012 at 09:20 PM.

  7. #7
    Registered User
    Join Date
    11-29-2012
    Location
    ystfast
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Remove text between "\" regardless of number of characters

    A very good point, I will give that a try also.

+ 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