+ Reply to Thread
Results 1 to 12 of 12

Remove Characters From Right of String

  1. #1
    Registered User
    Join Date
    12-26-2009
    Location
    London, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    6

    Question Remove Characters From Right of String

    Hello,

    I'm trying to remove everything after a specific character in a string.

    I.e. change a website address to the hostname

    http://www.excelforum.com/newthread.php
    http://usa.excelforum.com/forum/new

    to

    excelforum.com
    usa.excelforum.com

    I'm using this formula, which strips the http:// and the www., but does not replace the characters after the first remaining "/" as the wildcard is not recognized.

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"www.",""), A2,"http://",""), A2, "/*", "")

    Any help would be appreciated :-)

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

    Re: Remove Characters From Right of String

    Try this:
    Please Login or Register  to view this content.
    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Valued Forum Contributor Rahul Nagar's Avatar
    Join Date
    09-18-2008
    Location
    nasik
    MS-Off Ver
    Excel 2003
    Posts
    465

    Re: Remove Characters From Right of String

    Hi Ron Coderre,

    Thamx for the reply!!

    www. can not be removed by using the formula which is given by you.


    Hi Milagros,

    I would suggest you to use following method.
    1st find and replace with blank www. and http://
    2st use Text to columns >> Delimited>> Other " / "

    Regards
    __________________
    Regards
    Rahul Nagar
    Founder of www.myshortcutkeys.com.


    If you get the answer of your questions then please click EDIT in your original post then click on GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody! ....
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.

  4. #4
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Remove Characters From Right of String

    This could be easly done in VBA could be changed to suit your needs better.
    Please Login or Register  to view this content.
    cheers

    edit,
    i know nothink about formulars after playing with the one ron supplied
    Please Login or Register  to view this content.
    seams to do the same as the vba.

    good luck.
    Last edited by D_Rennie; 12-26-2009 at 10:54 AM.


  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Remove Characters From Right of String

    This seams to work for your examples
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-26-2009
    Location
    London, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Remove Characters From Right of String

    Thanks to Ron, Rahul and D_Rennie for replying! Much Appreciated :-)

    I do need the formula to be dynamic as I will be making changes to the sheet and to ensure that I don't need to run a Macro every time I need to make changes.

    I've worked with Ron's example to come up with a TWO column formula which does the trick.

    B2
    =SUBSTITUTE(A2,"www.","")

    C2
    =MID(B2,FIND("//",B2)+2,FIND("|",SUBSTITUTE(B2, "/","|",3))-FIND("//",B2)-2)

    This works perfectly, other than it taking up an extra column.

    When I tried to merge the pattern, I got lost again.. is possible to put this one column?

    =MID(A2,FIND("//",A2)+2,FIND("|",SUBSTITUTE(SUBSTITUTE(A2,"www.",""), "/","|",3))-FIND("//",A2)-2)

    Thanks again to all who replied :-)

  7. #7
    Registered User
    Join Date
    12-26-2009
    Location
    London, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    6

    Thumbs up Re: Remove Characters From Right of String

    Oh, looks like I got beaten to the punch while I was posting my last reply.

    Dave's workaround is perfect! It places the formula in one column and addresses the www. issue!

    PROBLEM SOLVED!!!

    Thanks Dave :-) , and again, Thanks to Ron, Rahul and D_Rennie as well!

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Remove Characters From Right of String

    Perhaps try

    =SUBSTITUTE(MID(A2,8,FIND("/",A2,FIND("//",A2)+2)-8),"www.","")

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

    Re: Remove Characters From Right of String

    Sorry....I missed the part about eliminating "www.".
    Try this:

    Please Login or Register  to view this content.
    Is that something you can work with?

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Remove Characters From Right of String

    In fact you can shorten my suggestion as follows:

    =SUBSTITUTE(MID(A2,8,FIND("/",A2,8)-8),"www.","")

    ...assumes that all your addresses begin with "http://"

  11. #11
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Remove Characters From Right of String

    seams like there are a lot of great people on here with not a heck to do. the amount of refinement is staggering. milagros deffently got some great input here. rep for everyone.

  12. #12
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Remove Characters From Right of String

    Quote Originally Posted by Ron Coderre View Post
    Sorry....I missed the part about eliminating "www.".
    Try this:

    Please Login or Register  to view this content.
    Is that something you can work with?
    Nice one, I will try to remember this.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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