+ Reply to Thread
Results 1 to 14 of 14

Remove all characters after third instance of /

  1. #1
    Registered User
    Join Date
    03-31-2008
    Posts
    11

    Remove all characters after third instance of /

    I'm trying to clean up a database of links and I need to remove everything after the third instance of a /

    I've been googling but haven't found anything like this yet.

    Thank you.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,604

    Re: Remove all characters after third instance of /

    Give us a few examples to practice on.

    Pete

  3. #3
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Remove all characters after third instance of /

    Something I learnt from one of the gurus here, I think it's called.. padding with spaces and trim? Anyhoo, formulas something like this.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by quekbc; 09-02-2015 at 08:04 PM. Reason: Edit following Pete_UK's advice, re-edited after OPs post

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,604

    Re: Remove all characters after third instance of /

    I think you need to keep the "/" in there, so replace "/" with "/" plus a load of spaces.

    Pete

  5. #5
    Registered User
    Join Date
    03-31-2008
    Posts
    11

    Re: Remove all characters after third instance of /

    So here is a random web link.

    http://www.iconarchive.com/show/soft...xcel-icon.html

    But I only want the link to be this, http://www.iconarchive.com, and not all the garbage after it.

    Does that help?

  6. #6
    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: Remove all characters after third instance of /

    Quote Originally Posted by djbetterly View Post
    So here is a random web link.

    http://www.iconarchive.com/show/soft...xcel-icon.html

    But I only want the link to be this, http://www.iconarchive.com, and not all the garbage after it.

    Does that help?
    The formula given in post#3 with do that.
    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

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Remove all characters after third instance of /

    Quote Originally Posted by djbetterly View Post
    I'm trying to clean up a database of links and I need to remove everything after the third instance of a /
    Does that mean you want to extract everything up to the 3rd / ?

    One/Two/Three/Four/Five/

    Would result in: One/Two/Three/
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  8. #8
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Remove all characters after third instance of /

    See my post on #3. That should work.

  9. #9
    Registered User
    Join Date
    03-31-2008
    Posts
    11

    Re: Remove all characters after third instance of /

    no, everything AFTER the third...

  10. #10
    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,917

    Re: Remove all characters after third instance of /

    2 options...
    =LEFT(A2,FIND("@",SUBSTITUTE(A2,"/","@",3),1)-1)
    =LEFT(A2,FIND(".com",A2,1)+3)

    The 2nd 1 may not work properly if there is more than 1 .com
    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

  11. #11
    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: Remove all characters after third instance of /

    or this

    =LEFT(A1,FIND("/",A1,FIND("/",A1,FIND("/",A1)+1)+1)-1)

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Remove all characters after third instance of /

    Quote Originally Posted by djbetterly View Post
    So here is a random web link.

    http://www.iconarchive.com/show/soft...xcel-icon.html

    But I only want the link to be this, http://www.iconarchive.com, and not all the garbage after it.

    Does that help?
    Try this...

    A1 = url

    =LEFT(A1,FIND("^",SUBSTITUTE(A1,"/","^",3))-1)

  13. #13
    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,917

    Re: Remove all characters after third instance of /

    Quote Originally Posted by djbetterly View Post
    no, everything AFTER the third...
    OK, you need to make up your mind lol...do you want the string BEFORE the 3rd / or AFTER the 3rd /

  14. #14
    Registered User
    Join Date
    03-31-2008
    Posts
    11

    Re: Remove all characters after third instance of /

    string from post #3 worked perfect! had to mod it a bit but it worked. Thank you guys. Sorry for any confusion.

+ 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. [SOLVED] VBA, remove all characters within a string, except numerical characters and full stops
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-25-2015, 09:24 PM
  2. [SOLVED] Remove all characters before or after X# of characters
    By Ocean Zhang in forum Excel General
    Replies: 8
    Last Post: 07-22-2014, 12:13 AM
  3. Remove instance variable from User Define Class
    By rubedario_86 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2013, 01:47 AM
  4. Replies: 3
    Last Post: 02-08-2012, 06:26 AM
  5. Remove all but one instance of a value in one column based on records in another colu
    By TheCyrusVirus in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-20-2010, 11:31 AM
  6. Replies: 9
    Last Post: 06-19-2009, 03:38 PM
  7. [SOLVED] How to return # characters based on 2nd instance of value
    By JDay01 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-19-2005, 01:06 PM

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