+ Reply to Thread
Results 1 to 13 of 13

Removing part of a string (trimming a text)

  1. #1
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Removing part of a string (trimming a text)

    Hello:
    Lets say I have the following:
    HTML Code: 
    I am trying to get only the second http address and cut out the google part (i.e I want only things after the "&url=" to remain). I would appreciate some help with a VBA program that would look in cells in a given column and perform this.

    Thanks

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Removing part of a string (trimming a text)

    Something like this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Removing part of a string (trimming a text)

    Another option:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Removing part of a string (trimming a text)

    Thank you very much for your help guys. Unfortunately, I can't get Norie's code to work and I am not sure why. Would mind checking it again? Thanks.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Removing part of a string (trimming a text)

    How isn't it working?

    It would need to go in a sub, have you done that?

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Removing part of a string (trimming a text)

    Norie, I don't know if Rng.value <> "" is correct - this will stop looping when the value is not equal to ""? I think you need Range.value = ""

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Removing part of a string (trimming a text)

    You are right, mixed up my Do While and Do Until.

    The code would still have run though, forever......

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Removing part of a string (trimming a text)

    I think as soon as it encounters a cell with text in it will exit the loop and then the macro. It would only run for ever (or at least to the bottom row) if all your cells in column A were blank.

    For what it's worth this works for me:
    Please Login or Register  to view this content.
    If I put the address I want in A2

  9. #9
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Removing part of a string (trimming a text)

    So, what's happening is that after putting it in a sub and clicked run, nothing happens.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Removing part of a string (trimming a text)

    Forever, never... it's a typo.

  11. #11
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Removing part of a string (trimming a text)

    Thank you both, I think it is working now! That was just a typo, i understand. Just as a follow up, is it possible to have the new link replace the content of the original cell? Now, it is dumping the link into Column B, but would be nice to have it do the change in A.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Removing part of a string (trimming a text)

    Remove Offset(,1).
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    06-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Removing part of a string (trimming a text)

    Thanks for your help!

+ 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