+ Reply to Thread
Results 1 to 15 of 15

Formula to Extract URL & Text from Href Tag

  1. #1
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    115

    Formula to Extract URL & Text from Href Tag

    I figured out a workaround in Google Sheets but I can't figure it out in Excel.

    <a href="http://www.smartinsights.com/mobile-marketing/mobile-marketing-analytics/mobile-marketing-statistics/">new report</a>

    I'd like a way to separate the URL and link text from above into 2 columns

    A B
    http://www.smartinsights.com/mobile-...ng-statistics/ new report

    Thanks for any suggestions.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Formula to Extract URL & Text from Href Tag

    You have given a sample of one, so this may work for your example, but not for other scenario:

    =MID(A1,FIND("http",A1),FIND(">",A1)-FIND("http",A1)-1)

    and

    =MID(A1,FIND(">",A1)+1,FIND("</a>",A1)-FIND(">",A1)-1)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to Extract URL & Text from Href Tag

    One way of many:

    URL =LEFT(MID(A1,FIND("""",A1)+1,LEN(A1)),FIND("""",MID(A1,FIND("""",A1)+1,LEN(A1)))-1)

    Name =LEFT(MID(A1,FIND(">",A1)+1,LEN(A1)),FIND("<",MID(A1,FIND(">",A1)+1,LEN(A1)))-1)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    115

    Re: Formula to Extract URL & Text from Href Tag

    Both solutions worked! Thanks so much for your help.

  5. #5
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    115

    Re: Formula to Extract URL & Text from Href Tag

    For some reason, I can't access Edit to mark this post as Solved

  6. #6
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to Extract URL & Text from Href Tag

    little modyfication
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and drag accros

    Go to the first post, from Thread Tools select Mark as Solved

  7. #7
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to Extract URL & Text from Href Tag

    should be (COLUMN($A$10)+2)

    btw. I can't edit post

  8. #8
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    115

    Re: Formula to Extract URL & Text from Href Tag

    Thanks sandy666.

    That modified formula does work,but there is a problem. It starts at cell 10 instead of cell 2 (first cell is a column header)

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to Extract URL & Text from Href Tag

    If your URL and name is in B column
    =IF(COLUMN(C10)=(COLUMN($B$10)+2),MID($B$10,FIND(">",$B$10)+1,FIND("</a>",$B$10)-FIND(">",$B$10)-1),MID($B$10,FIND("http",$B$10),FIND(">",$B$10)-FIND("http",$B$10)-1))

  10. #10
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to Extract URL & Text from Href Tag

    simply change number of address to your needs

  11. #11
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    115

    Re: Formula to Extract URL & Text from Href Tag

    Sandy666,

    One last thing, and I promise to leave you alone.

    Is there a way for this to work on a relative path HREF (without http & domain)

    Ex: <a href="/work/next-generation-lighting/">&amp;mdash;Jay Andrews at NextGen Lighting</a>

  12. #12
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to Extract URL & Text from Href Tag

    If source is in B2
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  13. #13
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to Extract URL & Text from Href Tag

    If source is in B2 and sources are mixed (http or without http) you can try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    but first check it and change to addresses suitable to your needs.

  14. #14
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    115

    Re: Formula to Extract URL & Text from Href Tag

    That's Perfect. Thanks sandy666!

  15. #15
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to Extract URL & Text from Href Tag

    Happy to help
    If it's helped you add reputation star and mark thread as solved
    Thank you.

+ 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. Checking when Href tag is missing.
    By V1cman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2016, 04:45 PM
  2. [SOLVED] Need help with text extract formula
    By SEMMatt in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-09-2014, 07:52 PM
  3. [SOLVED] Get href links from a website
    By Sean Thomas in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-30-2013, 05:59 PM
  4. [SOLVED] Extract text from a string of text (amend formula to include new criteria)
    By robertguy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-10-2013, 04:53 PM
  5. [SOLVED] XMLSS href attribute
    By Pete Hodgson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-23-2005, 06:05 PM
  6. Can I extract text as a value from a formula?
    By Amy O in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-07-2005, 09:06 PM
  7. Can I extract text as a value from a formula?
    By Amy O in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-07-2005, 07: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